diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-08-27 09:44:05 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-27 09:44:05 +0000 |
commit | 9103939fa98de53170d2bf0e8cd74529786d7ab2 (patch) | |
tree | 06f7b96b861ad32642a8a70fdbeaf49ae755c3d0 /service/static/service.go | |
parent | 88b394324165e3e16253c27552b0d4d7d6628a81 (diff) | |
parent | 66848c53fa63439c5c77857187b86f5bf31d1321 (diff) |
Merge #345
345: Adding headers to static files r=48d90782 a=siad007
Fixes #336
Related to #335
Co-authored-by: Siad Ardroumli <[email protected]>
Co-authored-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'service/static/service.go')
-rw-r--r-- | service/static/service.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/service/static/service.go b/service/static/service.go index b824e787..95b99860 100644 --- a/service/static/service.go +++ b/service/static/service.go @@ -36,6 +36,18 @@ func (s *Service) Init(cfg *Config, r *rrhttp.Service) (bool, error) { func (s *Service) middleware(f http.HandlerFunc) http.HandlerFunc { // Define the http.HandlerFunc return func(w http.ResponseWriter, r *http.Request) { + if s.cfg.Request != nil { + for k, v := range s.cfg.Request { + r.Header.Add(k, v) + } + } + + if s.cfg.Response != nil { + for k, v := range s.cfg.Response { + w.Header().Set(k, v) + } + } + if !s.handleStatic(w, r) { f(w, r) } |