2021-09-29 15:38:50 +00:00
|
|
|
// Package env contains all about environment variables, that can be used by current application.
|
|
|
|
package env
|
|
|
|
|
|
|
|
import "os"
|
|
|
|
|
|
|
|
type envVariable string
|
|
|
|
|
|
|
|
const (
|
2023-01-29 10:54:56 +00:00
|
|
|
LogLevel envVariable = "LOG_LEVEL" // logging level
|
|
|
|
LogFormat envVariable = "LOG_FORMAT" // logging format (json|console)
|
|
|
|
|
2021-10-06 17:38:00 +00:00
|
|
|
ListenAddr envVariable = "LISTEN_ADDR" // IP address for listening
|
|
|
|
ListenPort envVariable = "LISTEN_PORT" // port number for listening
|
|
|
|
TemplateName envVariable = "TEMPLATE_NAME" // template name
|
|
|
|
ConfigFilePath envVariable = "CONFIG_FILE" // path to the config file
|
|
|
|
DefaultErrorPage envVariable = "DEFAULT_ERROR_PAGE" // default error page (code)
|
2022-01-03 16:51:30 +00:00
|
|
|
DefaultHTTPCode envVariable = "DEFAULT_HTTP_CODE" // default HTTP response code
|
2022-01-27 12:29:49 +00:00
|
|
|
ShowDetails envVariable = "SHOW_DETAILS" // show request details in response
|
2022-02-23 06:09:54 +00:00
|
|
|
ProxyHTTPHeaders envVariable = "PROXY_HTTP_HEADERS" // proxy HTTP request headers list (request -> response)
|
2022-04-12 10:34:35 +00:00
|
|
|
DisableL10n envVariable = "DISABLE_L10N" // disable pages localization
|
2023-09-01 06:17:11 +00:00
|
|
|
CatchAll envVariable = "CATCH_ALL" // catch all pages
|
2023-11-20 08:27:40 +00:00
|
|
|
ReadBufferSize envVariable = "READ_BUFFER_SIZE" // https://github.com/tarampampam/error-pages/issues/238
|
2021-09-29 15:38:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// String returns environment variable name in the string representation.
|
|
|
|
func (e envVariable) String() string { return string(e) }
|
|
|
|
|
|
|
|
// Lookup retrieves the value of the environment variable. If the variable is present in the environment the value
|
|
|
|
// (which may be empty) is returned and the boolean is true. Otherwise the returned value will be empty and the
|
|
|
|
// boolean will be false.
|
|
|
|
func (e envVariable) Lookup() (string, bool) { return os.LookupEnv(string(e)) }
|