From 1f3ae665ed2e58ca572678ce7caf8b711f226392 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Tue, 29 Nov 2022 20:59:31 +0100 Subject: Introduce EDIT and MANAGE methods All admin "index" pages are moved under MANAGE, so that we can have (for example) and normal "GET /posts" page later which would replace the current index page, and potentially corresponding pages for the other categories. The EDIT method replaces the old `?edit` pattern, which normalizes how we differentiate page functionality generally. --- src/http/apiutil/apiutil.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/http/apiutil/apiutil.go') diff --git a/src/http/apiutil/apiutil.go b/src/http/apiutil/apiutil.go index fed6fb5..1fbadea 100644 --- a/src/http/apiutil/apiutil.go +++ b/src/http/apiutil/apiutil.go @@ -120,6 +120,9 @@ func RandStr(numBytes int) string { // // If the method "*" is defined then all methods not defined will be directed to // that handler, and 405 Method Not Allowed is never returned. +// +// If the GET argument 'method' is present then the ToUpper of that is taken to +// be the name of the method. func MethodMux(handlers map[string]http.Handler) http.Handler { return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { @@ -127,7 +130,7 @@ func MethodMux(handlers map[string]http.Handler) http.Handler { method := strings.ToUpper(r.Method) formMethod := strings.ToUpper(r.FormValue("method")) - if method == "POST" && formMethod != "" { + if formMethod != "" { method = formMethod } -- cgit v1.2.3