Add headers config, closes #25
This commit is contained in:
parent
6aaa2b521d
commit
8526805c2f
@ -68,3 +68,7 @@ enabled = false
|
|||||||
max_age = 31536000
|
max_age = 31536000
|
||||||
include_subdomains = false
|
include_subdomains = false
|
||||||
preload = 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
|
Dev bool
|
||||||
HexIP bool
|
HexIP bool
|
||||||
VerifyCertificates bool `mapstructure:"verify_certificates"`
|
VerifyCertificates bool `mapstructure:"verify_certificates"`
|
||||||
|
Headers map[string]string
|
||||||
Defaults *Defaults
|
Defaults *Defaults
|
||||||
HTTPS *HTTPS
|
HTTPS *HTTPS
|
||||||
LetsEncrypt *LetsEncrypt
|
LetsEncrypt *LetsEncrypt
|
||||||
|
@ -323,6 +323,10 @@ func (d *Dispatch) serveIndex(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Strict-Transport-Security", hstsHeader)
|
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") {
|
if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
|
||||||
w.Header().Set("Content-Encoding", "gzip")
|
w.Header().Set("Content-Encoding", "gzip")
|
||||||
w.Header().Set("Content-Length", indexPageLen)
|
w.Header().Set("Content-Length", indexPageLen)
|
||||||
|
Loading…
Reference in New Issue
Block a user