You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
418B

  1. package middleware
  2. import "net/http"
  3. // Header adds the given response headers to the upcoming `http.ResponseWriter`.
  4. func Header(values map[string]string) func(http.Handler) http.Handler {
  5. return func(next http.Handler) http.Handler {
  6. return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  7. for key, value := range values {
  8. w.Header().Set(key, value)
  9. }
  10. next.ServeHTTP(w, r)
  11. })
  12. }
  13. }