From 034342421bd0b3d40276df79a0f2450d1fbd643f Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Fri, 20 May 2022 19:29:01 -0600 Subject: Simplify routes by moving formMiddleware to the global level --- srv/src/http/apiutil/apiutil.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'srv/src/http/apiutil') diff --git a/srv/src/http/apiutil/apiutil.go b/srv/src/http/apiutil/apiutil.go index d427b65..aa62299 100644 --- a/srv/src/http/apiutil/apiutil.go +++ b/srv/src/http/apiutil/apiutil.go @@ -121,10 +121,11 @@ func MethodMux(handlers map[string]http.Handler) http.Handler { return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { - method := strings.ToUpper(r.FormValue("method")) + method := strings.ToUpper(r.Method) + formMethod := strings.ToUpper(r.FormValue("method")) - if method == "" { - method = strings.ToUpper(r.Method) + if method == "POST" && formMethod != "" { + method = formMethod } handler, ok := handlers[method] -- cgit v1.2.3