MCPcopy Index your code
hub / github.com/labstack/echo / TestMethodOverride_queryParam

Function TestMethodOverride_queryParam

middleware/method_override_test.go:56–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func TestMethodOverride_queryParam(t *testing.T) {
57 e := echo.New()
58 h := func(c *echo.Context) error {
59 return c.String(http.StatusOK, "test")
60 }
61
62 // Override with query parameter
63 m, err := MethodOverrideConfig{Getter: MethodFromQuery("_method")}.ToMiddleware()
64 assert.NoError(t, err)
65 req := httptest.NewRequest(http.MethodPost, "/?_method="+http.MethodDelete, nil)
66 rec := httptest.NewRecorder()
67 c := e.NewContext(req, rec)
68
69 err = m(h)(c)
70 assert.NoError(t, err)
71
72 assert.Equal(t, http.MethodDelete, req.Method)
73}
74
75func TestMethodOverride_ignoreGet(t *testing.T) {
76 e := echo.New()

Callers

nothing calls this directly

Calls 4

StringMethod · 0.95
MethodFromQueryFunction · 0.85
NewContextMethod · 0.80
ToMiddlewareMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…