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

Function TestEchoWrapMiddleware

echo_test.go:731–756  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

729}
730
731func TestEchoWrapMiddleware(t *testing.T) {
732 e := New()
733
734 var actualID string
735 var actualPattern string
736 e.Use(WrapMiddleware(func(h http.Handler) http.Handler {
737 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
738 actualID = r.PathValue("id")
739 actualPattern = r.Pattern
740 h.ServeHTTP(w, r)
741 })
742 }))
743
744 e.GET("/:id", func(c *Context) error {
745 return c.String(http.StatusTeapot, "OK")
746 })
747
748 req := httptest.NewRequest(http.MethodGet, "/123", nil)
749 rec := httptest.NewRecorder()
750 e.ServeHTTP(rec, req)
751
752 assert.Equal(t, http.StatusTeapot, rec.Code)
753 assert.Equal(t, "OK", rec.Body.String())
754 assert.Equal(t, "123", actualID)
755 assert.Equal(t, "/:id", actualPattern)
756}
757
758func TestEchoConnect(t *testing.T) {
759 e := New()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
WrapMiddlewareFunction · 0.85
ServeHTTPMethod · 0.80
UseMethod · 0.45
GETMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…