func addCORSDefaults(c *cmdsHttp.ServerConfig) { // by default use localhost origins if len(c.AllowedOrigins()) == 0 { c.SetAllowedOrigins(defaultLocalhostOrigins...) } // by default, use GET, PUT, POST if len(c.AllowedMethods()) == 0 { c.SetAllowedMethods("GET", "POST", "PUT") } }
func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { log.Info("Using API.HTTPHeaders:", nc.API.HTTPHeaders) if acao := nc.API.HTTPHeaders[cmdsHttp.ACAOrigin]; acao != nil { c.SetAllowedOrigins(acao...) } if acam := nc.API.HTTPHeaders[cmdsHttp.ACAMethods]; acam != nil { c.SetAllowedMethods(acam...) } if acac := nc.API.HTTPHeaders[cmdsHttp.ACACredentials]; acac != nil { for _, v := range acac { c.SetAllowCredentials(strings.ToLower(v) == "true") } } c.Headers = nc.API.HTTPHeaders }