1package mox
2
3import (
4 "net/http"
5)
6
7// Set some http headers that should prevent potential abuse. Better safe than sorry.
8func SafeHeaders(fn http.Handler) http.Handler {
9 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
10 h := w.Header()
11 h.Set("X-Frame-Options", "deny")
12 h.Set("X-Content-Type-Options", "nosniff")
13 h.Set("Content-Security-Policy", "default-src 'self' 'unsafe-inline' data:")
14 h.Set("Referrer-Policy", "same-origin")
15 fn.ServeHTTP(w, r)
16 })
17}
18