[#158] Support cors
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
901b8ff95b
commit
46c63edd67
6 changed files with 201 additions and 16 deletions
|
@ -56,6 +56,8 @@ const (
|
|||
|
||||
defaultReconnectInterval = time.Minute
|
||||
|
||||
defaultCORSMaxAge = 600 // seconds
|
||||
|
||||
cfgServer = "server"
|
||||
cfgTLSEnabled = "tls.enabled"
|
||||
cfgTLSCertFile = "tls.cert_file"
|
||||
|
@ -141,6 +143,14 @@ const (
|
|||
cfgResolveNamespaceHeader = "resolve_bucket.namespace_header"
|
||||
cfgResolveDefaultNamespaces = "resolve_bucket.default_namespaces"
|
||||
|
||||
// CORS.
|
||||
cfgCORSAllowOrigin = "cors.allow_origin"
|
||||
cfgCORSAllowMethods = "cors.allow_methods"
|
||||
cfgCORSAllowHeaders = "cors.allow_headers"
|
||||
cfgCORSExposeHeaders = "cors.expose_headers"
|
||||
cfgCORSAllowCredentials = "cors.allow_credentials"
|
||||
cfgCORSMaxAge = "cors.max_age"
|
||||
|
||||
// Command line args.
|
||||
cmdHelp = "help"
|
||||
cmdVersion = "version"
|
||||
|
@ -537,6 +547,15 @@ func fetchDefaultNamespaces(v *viper.Viper) []string {
|
|||
return namespaces
|
||||
}
|
||||
|
||||
func fetchCORSMaxAge(v *viper.Viper) int {
|
||||
maxAge := v.GetInt(cfgCORSMaxAge)
|
||||
if maxAge <= 0 {
|
||||
maxAge = defaultCORSMaxAge
|
||||
}
|
||||
|
||||
return maxAge
|
||||
}
|
||||
|
||||
func fetchServers(v *viper.Viper, log *zap.Logger) []ServerInfo {
|
||||
var servers []ServerInfo
|
||||
seen := make(map[string]struct{})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue