package main import "net/http" func WithMethod(method string, next http.Handler) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if r.Method != method { w.WriteHeader(http.StatusMethodNotAllowed) w.Write([]byte("Method Not Allowed")) return } next.ServeHTTP(w, r) } } func WithForm(next http.Handler) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if err := r.ParseForm(); err != nil { w.WriteHeader(http.StatusBadRequest) w.Write([]byte("Bad Request")) return } next.ServeHTTP(w, r) } }