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

Function TestDecompressSkipper

middleware/decompress_test.go:161–180  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

159}
160
161func TestDecompressSkipper(t *testing.T) {
162 e := echo.New()
163 e.Use(DecompressWithConfig(DecompressConfig{
164 Skipper: func(c *echo.Context) bool {
165 return c.Request().URL.Path == "/skip"
166 },
167 }))
168 body := `{"name": "echo"}`
169 req := httptest.NewRequest(http.MethodPost, "/skip", strings.NewReader(body))
170 req.Header.Set(echo.HeaderContentEncoding, GZIPEncoding)
171 rec := httptest.NewRecorder()
172 c := e.NewContext(req, rec)
173
174 e.ServeHTTP(rec, req)
175
176 assert.Equal(t, rec.Header().Get(echo.HeaderContentType), echo.MIMEApplicationJSON)
177 reqBody, err := io.ReadAll(c.Request().Body)
178 assert.NoError(t, err)
179 assert.Equal(t, body, string(reqBody))
180}
181
182type TestDecompressPoolWithError struct {
183}

Callers

nothing calls this directly

Calls 8

RequestMethod · 0.95
DecompressWithConfigFunction · 0.85
SetMethod · 0.80
NewContextMethod · 0.80
ServeHTTPMethod · 0.80
UseMethod · 0.45
GetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…