MCPcopy
hub / github.com/go-chi/chi / TestRouterFromMuxWith

Function TestRouterFromMuxWith

mux_test.go:734–752  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

732}
733
734func TestRouterFromMuxWith(t *testing.T) {
735 t.Parallel()
736
737 r := NewRouter()
738
739 with := r.With(func(next http.Handler) http.Handler {
740 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
741 next.ServeHTTP(w, r)
742 })
743 })
744
745 with.Get("/with_middleware", func(w http.ResponseWriter, r *http.Request) {})
746
747 ts := httptest.NewServer(with)
748 defer ts.Close()
749
750 // Without the fix this test was committed with, this causes a panic.
751 testRequest(t, ts, http.MethodGet, "/with_middleware", nil)
752}
753
754func TestMuxMiddlewareStack(t *testing.T) {
755 var stdmwInit, stdmwHandler uint64

Callers

nothing calls this directly

Calls 7

WithMethod · 0.95
NewRouterFunction · 0.85
HandlerFuncMethod · 0.80
CloseMethod · 0.80
testRequestFunction · 0.70
GetMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected