From 73603079e29bc89c54296a9e12b5a779cd84c023 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 2 May 2024 23:18:19 +0200 Subject: feat: serve a very basic html template --- internal/server/headers.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 internal/server/headers.go (limited to 'internal/server/headers.go') diff --git a/internal/server/headers.go b/internal/server/headers.go new file mode 100644 index 0000000..0efc384 --- /dev/null +++ b/internal/server/headers.go @@ -0,0 +1,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) + }) +} -- cgit 1.4.1