MCPcopy Index your code
hub / github.com/dnote/dnote / methodOverride

Function methodOverride

pkg/server/middleware/middleware.go:32–44  ·  view source on GitHub ↗

methodOverride overrides the request's method to simulate form actions that are not natively supported by web browsers

(next http.Handler)

Source from the content-addressed store, hash-verified

30// methodOverride overrides the request's method to simulate form actions that
31// are not natively supported by web browsers
32func 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
47func WebMw(h http.Handler, app *app.App, rateLimit bool) http.Handler {

Callers 1

GlobalFunction · 0.85

Calls 1

ServeHTTPMethod · 0.80

Tested by

no test coverage detected