hsts.go 335 B

12345678910111213
  1. package middleware
  2. import (
  3. "net/http"
  4. )
  5. // HSTS is a middleware to enabling HSTS on HTTP requests
  6. func HSTS(inner http.Handler) http.Handler {
  7. return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  8. w.Header().Set("Strict-Transport-Security", "max-age=15768000 ; includeSubDomains")
  9. inner.ServeHTTP(w, r)
  10. })
  11. }