Ejemplo n.º 1
0
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.CORSOpts.AllowedOrigins = acao
	}
	if acam := nc.API.HTTPHeaders[cmdsHttp.ACAMethods]; acam != nil {
		c.CORSOpts.AllowedMethods = acam
	}
	if acac := nc.API.HTTPHeaders[cmdsHttp.ACACredentials]; acac != nil {
		for _, v := range acac {
			c.CORSOpts.AllowCredentials = (strings.ToLower(v) == "true")
		}
	}

	c.Headers = nc.API.HTTPHeaders
}