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

Function TestBodyLimitWithConfig

middleware/body_limit_test.go:149–169  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

147}
148
149func TestBodyLimitWithConfig(t *testing.T) {
150 e := echo.New()
151 hw := []byte("Hello, World!")
152 req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw))
153 rec := httptest.NewRecorder()
154 c := e.NewContext(req, rec)
155 h := func(c *echo.Context) error {
156 body, err := io.ReadAll(c.Request().Body)
157 if err != nil {
158 return err
159 }
160 return c.String(http.StatusOK, string(body))
161 }
162
163 mw := BodyLimitWithConfig(BodyLimitConfig{LimitBytes: 2 * MB})
164
165 err := mw(h)(c)
166 assert.NoError(t, err)
167 assert.Equal(t, http.StatusOK, rec.Code)
168 assert.Equal(t, hw, rec.Body.Bytes())
169}
170
171func TestBodyLimit(t *testing.T) {
172 e := echo.New()

Callers

nothing calls this directly

Calls 4

RequestMethod · 0.95
StringMethod · 0.95
BodyLimitWithConfigFunction · 0.85
NewContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…