Middleware: Add Custom Headers to HTTP responses (#59018)

* Middleware: Add Custom Headers to HTTP responses

* Update docs/sources/setup-grafana/configure-grafana/_index.md

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>

* Update conf/defaults.ini

Co-authored-by: Dave Henderson <dave.henderson@grafana.com>

* Update conf/sample.ini

Co-authored-by: Dave Henderson <dave.henderson@grafana.com>

* Update _index.md

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
This commit is contained in:
João Calisto
2022-11-30 17:12:34 +00:00
committed by GitHub
co-authored by Christopher Moyer Dave Henderson
parent 9cdb6b07c7
commit bba42b113c
7 changed files with 65 additions and 0 deletions
+10
View File
@@ -486,6 +486,8 @@ type Cfg struct {
GRPCServerNetwork string
GRPCServerAddress string
GRPCServerTLSConfig *tls.Config
CustomResponseHeaders map[string]string
}
type CommandLineArgs struct {
@@ -1692,6 +1694,14 @@ func (cfg *Cfg) readServerSettings(iniFile *ini.File) error {
cfg.ReadTimeout = server.Key("read_timeout").MustDuration(0)
headersSection := cfg.Raw.Section("server.custom_response_headers")
keys := headersSection.Keys()
cfg.CustomResponseHeaders = make(map[string]string, len(keys))
for _, key := range keys {
cfg.CustomResponseHeaders[key.Name()] = key.Value()
}
return nil
}