Add headers config, closes #25
This commit is contained in:
parent
6aaa2b521d
commit
8526805c2f
@ -68,3 +68,7 @@ enabled = false
|
||||
max_age = 31536000
|
||||
include_subdomains = false
|
||||
preload = false
|
||||
|
||||
# Add your own HTTP headers to the index page
|
||||
[headers]
|
||||
# X-Example = "Rainbows"
|
||||
|
@ -14,6 +14,7 @@ type Config struct {
|
||||
Dev bool
|
||||
HexIP bool
|
||||
VerifyCertificates bool `mapstructure:"verify_certificates"`
|
||||
Headers map[string]string
|
||||
Defaults *Defaults
|
||||
HTTPS *HTTPS
|
||||
LetsEncrypt *LetsEncrypt
|
||||
|
@ -323,6 +323,10 @@ func (d *Dispatch) serveIndex(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Strict-Transport-Security", hstsHeader)
|
||||
}
|
||||
|
||||
for k, v := range d.Config().Headers {
|
||||
w.Header().Set(k, v)
|
||||
}
|
||||
|
||||
if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
|
||||
w.Header().Set("Content-Encoding", "gzip")
|
||||
w.Header().Set("Content-Length", indexPageLen)
|
||||
|
Loading…
Reference in New Issue
Block a user