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

Function TestResponse

response_test.go:14–32  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestResponse(t *testing.T) {
15 e := New()
16 req := httptest.NewRequest(http.MethodGet, "/", nil)
17 rec := httptest.NewRecorder()
18 c := e.NewContext(req, rec)
19 res := NewResponse(rec, e.Logger)
20
21 // Before
22 res.Before(func() {
23 c.Response().Header().Set(HeaderServer, "echo")
24 })
25 // After
26 res.After(func() {
27 c.Response().Header().Set(HeaderXFrameOptions, "DENY")
28 })
29 res.Write([]byte("test"))
30 assert.Equal(t, "echo", rec.Header().Get(HeaderServer))
31 assert.Equal(t, "DENY", rec.Header().Get(HeaderXFrameOptions))
32}
33
34func TestResponse_Write_FallsBackToDefaultStatus(t *testing.T) {
35 e := New()

Callers

nothing calls this directly

Calls 10

BeforeMethod · 0.95
ResponseMethod · 0.95
AfterMethod · 0.95
WriteMethod · 0.95
NewFunction · 0.85
NewResponseFunction · 0.85
NewContextMethod · 0.80
SetMethod · 0.80
HeaderMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…