package methodsallowed import "net/http" func Allow(methods ...string) func(http.Handler) http.Handler { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { for _, m := range methods { if r.Method == m { next.ServeHTTP(w, r) return } } http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) }) } }