您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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. }