MCPcopy
hub / github.com/labstack/echo / TestMethodOverride_formParam

Function TestMethodOverride_formParam

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

Source from the content-addressed store, hash-verified

34}
35
36func TestMethodOverride_formParam(t *testing.T) {
37 e := echo.New()
38 h := func(c *echo.Context) error {
39 return c.String(http.StatusOK, "test")
40 }
41
42 // Override with form parameter
43 m, err := MethodOverrideConfig{Getter: MethodFromForm("_method")}.ToMiddleware()
44 assert.NoError(t, err)
45 req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader([]byte("_method="+http.MethodDelete)))
46 rec := httptest.NewRecorder()
47 req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationForm)
48 c := e.NewContext(req, rec)
49
50 err = m(h)(c)
51 assert.NoError(t, err)
52
53 assert.Equal(t, http.MethodDelete, req.Method)
54}
55
56func TestMethodOverride_queryParam(t *testing.T) {
57 e := echo.New()

Callers

nothing calls this directly

Calls 5

StringMethod · 0.95
MethodFromFormFunction · 0.85
SetMethod · 0.80
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…