mirror of
https://github.com/halverneus/static-file-server.git
synced 2024-11-24 09:05:30 +00:00
Update congif to support CORS
This commit is contained in:
parent
3434133796
commit
91c955e52e
@ -23,6 +23,7 @@ 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`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ const (
|
|||||||
tlsCertKey = "TLS_CERT"
|
tlsCertKey = "TLS_CERT"
|
||||||
tlsKeyKey = "TLS_KEY"
|
tlsKeyKey = "TLS_KEY"
|
||||||
urlPrefixKey = "URL_PREFIX"
|
urlPrefixKey = "URL_PREFIX"
|
||||||
|
corsKey = "CORS"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -48,6 +50,7 @@ var (
|
|||||||
defaultTLSCert = ""
|
defaultTLSCert = ""
|
||||||
defaultTLSKey = ""
|
defaultTLSKey = ""
|
||||||
defaultURLPrefix = ""
|
defaultURLPrefix = ""
|
||||||
|
defaultCors = false
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -65,6 +68,7 @@ func setDefaults() {
|
|||||||
Get.TLSCert = defaultTLSCert
|
Get.TLSCert = defaultTLSCert
|
||||||
Get.TLSKey = defaultTLSKey
|
Get.TLSKey = defaultTLSKey
|
||||||
Get.URLPrefix = defaultURLPrefix
|
Get.URLPrefix = defaultURLPrefix
|
||||||
|
Get.Cors = defaultCors
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the configuration file.
|
// Load the configuration file.
|
||||||
@ -113,6 +117,7 @@ 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.
|
||||||
|
Loading…
Reference in New Issue
Block a user