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.

header.go 409B

9 yıl önce
123456789101112131415
  1. package middleware
  2. import "net/http"
  3. // Header adds the given response headers to the upcoming `http.ResponseWriter`.
  4. func Header(values http.Header) 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()[key] = value
  9. }
  10. next.ServeHTTP(w, r)
  11. })
  12. }
  13. }