summaryrefslogtreecommitdiff
path: root/http/middleware.go
blob: f2fe90d573c2863c0bd89d258a143c82f58786da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package http

import "net/http"

func IsFormContentCheck(innerHandler http.Handler) http.Handler {
	outerHandler := func(w http.ResponseWriter, r *http.Request) {
		// TOdo:
		contentType := r.Header.Get("Content-Type")
		if contentType != "application/x-www-form-urlencoded" {
			w.WriteHeader(http.StatusNotAcceptable)
			return
		}
		innerHandler.ServeHTTP(w, r)
	}
	return http.HandlerFunc(outerHandler)
}