package http import "net/http" func CorsMiddleware(next http.Handler, origin string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Credentials", "true") w.Header().Set("Access-Control-Allow-Methods", "POST,GET") w.Header().Set("Access-Control-Allow-Origin", origin) next.ServeHTTP(w, r) }) } func ContentTypeMiddleware(next http.Handler, contentType string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Add("Content-Type", contentType) next.ServeHTTP(w, r) }) } func DoNotTrackMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if dnt := r.Header.Get("DNT"); dnt == "1" { w.WriteHeader(http.StatusNoContent) return } next.ServeHTTP(w, r) }) }