methodOverride overrides the request's method to simulate form actions that are not natively supported by web browsers
(next http.Handler)
| 30 | // methodOverride overrides the request's method to simulate form actions that |
| 31 | // are not natively supported by web browsers |
| 32 | func methodOverride(next http.Handler) http.Handler { |
| 33 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 34 | if r.Method == http.MethodPost { |
| 35 | method := r.PostFormValue(methodOverrideKey) |
| 36 | |
| 37 | if method == http.MethodPut || method == http.MethodPatch || method == http.MethodDelete { |
| 38 | r.Method = method |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | next.ServeHTTP(w, r) |
| 43 | }) |
| 44 | } |
| 45 | |
| 46 | // WebMw is the middleware for the web |
| 47 | func WebMw(h http.Handler, app *app.App, rateLimit bool) http.Handler { |