blob: 0efc38433fdfc5b0ece53ea6085e12a9d37113f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package server
import (
"net/http"
cfg "searchix/internal/config"
)
func AddHeadersMiddleware(next http.Handler, config *cfg.Config) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
for h, v := range config.Headers {
w.Header().Add(h, v)
}
w.Header().Add("Content-Security-Policy", config.CSP.String())
next.ServeHTTP(w, r)
})
}
|