Updated alphabetical ordering of flags and 80-column wordwrap.

This commit is contained in:
Jeromy Streets 2019-10-16 09:30:47 -07:00
parent b881912582
commit 0d80a644ff
3 changed files with 8 additions and 8 deletions

View File

@ -63,6 +63,7 @@ the path to the configuration file using the command line option
('-c', '-config', '--config'). ('-c', '-config', '--config').
```yaml ```yaml
cors: false
debug: false debug: false
folder: /web folder: /web
host: "" host: ""
@ -72,7 +73,6 @@ show-listing: true
tls-cert: "" tls-cert: ""
tls-key: "" tls-key: ""
url-prefix: "" url-prefix: ""
cors: false
``` ```
Example configuration with possible alternative values: Example configuration with possible alternative values:

View File

@ -34,9 +34,9 @@ DEPENDENCIES
ENVIRONMENT VARIABLES ENVIRONMENT VARIABLES
CORS CORS
When set to 'true' it enables resource access from any domain. All responses When set to 'true' it enables resource access from any domain. All
will include the headers 'Access-Control-Allow-Origin' and 'Access-Control-Allow-Headers' responses will include the headers 'Access-Control-Allow-Origin' and
with a wildcard value ('*'). 'Access-Control-Allow-Headers' with a wildcard value ('*').
DEBUG DEBUG
When set to 'true' enables additional logging, including the When set to 'true' enables additional logging, including the
configuration used and an access log for each request. IMPORTANT NOTE: configuration used and an access log for each request. IMPORTANT NOTE:
@ -89,6 +89,7 @@ CONFIGURATION FILE
Example config.yml with defaults: Example config.yml with defaults:
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
cors: false
debug: false debug: false
folder: /web folder: /web
host: "" host: ""
@ -98,7 +99,6 @@ CONFIGURATION FILE
tls-cert: "" tls-cert: ""
tls-key: "" tls-key: ""
url-prefix: "" url-prefix: ""
cors: false
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
Example config.yml with possible alternative values: Example config.yml with possible alternative values:

View File

@ -14,6 +14,7 @@ import (
var ( var (
// Get the desired configuration value. // Get the desired configuration value.
Get struct { Get struct {
Cors bool `yaml:"cors"`
Debug bool `yaml:"debug"` Debug bool `yaml:"debug"`
Folder string `yaml:"folder"` Folder string `yaml:"folder"`
Host string `yaml:"host"` Host string `yaml:"host"`
@ -23,11 +24,11 @@ var (
TLSKey string `yaml:"tls-key"` TLSKey string `yaml:"tls-key"`
URLPrefix string `yaml:"url-prefix"` URLPrefix string `yaml:"url-prefix"`
Referrers []string `yaml:"referrers"` Referrers []string `yaml:"referrers"`
Cors bool `yaml:cors`
} }
) )
const ( const (
corsKey = "CORS"
debugKey = "DEBUG" debugKey = "DEBUG"
folderKey = "FOLDER" folderKey = "FOLDER"
hostKey = "HOST" hostKey = "HOST"
@ -37,7 +38,6 @@ const (
tlsCertKey = "TLS_CERT" tlsCertKey = "TLS_CERT"
tlsKeyKey = "TLS_KEY" tlsKeyKey = "TLS_KEY"
urlPrefixKey = "URL_PREFIX" urlPrefixKey = "URL_PREFIX"
corsKey = "CORS"
) )
var ( var (
@ -108,6 +108,7 @@ func Log() {
// overrideWithEnvVars the default values and the configuration file values. // overrideWithEnvVars the default values and the configuration file values.
func overrideWithEnvVars() { func overrideWithEnvVars() {
// Assign envvars, if set. // Assign envvars, if set.
Get.Cors = envAsBool(corsKey, Get.Cors)
Get.Debug = envAsBool(debugKey, Get.Debug) Get.Debug = envAsBool(debugKey, Get.Debug)
Get.Folder = envAsStr(folderKey, Get.Folder) Get.Folder = envAsStr(folderKey, Get.Folder)
Get.Host = envAsStr(hostKey, Get.Host) Get.Host = envAsStr(hostKey, Get.Host)
@ -117,7 +118,6 @@ func overrideWithEnvVars() {
Get.TLSKey = envAsStr(tlsKeyKey, Get.TLSKey) Get.TLSKey = envAsStr(tlsKeyKey, Get.TLSKey)
Get.URLPrefix = envAsStr(urlPrefixKey, Get.URLPrefix) Get.URLPrefix = envAsStr(urlPrefixKey, Get.URLPrefix)
Get.Referrers = envAsStrSlice(referrersKey, Get.Referrers) Get.Referrers = envAsStrSlice(referrersKey, Get.Referrers)
Get.Cors = envAsBool(corsKey, Get.Cors)
} }
// validate the configuration. // validate the configuration.