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

Function testRequest

middleware/middleware_test.go:82–103  ·  view source on GitHub ↗
(t *testing.T, ts *httptest.Server, method, path string, body io.Reader)

Source from the content-addressed store, hash-verified

80}
81
82func testRequest(t *testing.T, ts *httptest.Server, method, path string, body io.Reader) (*http.Response, string) {
83 req, err := http.NewRequest(method, ts.URL+path, body)
84 if err != nil {
85 t.Fatal(err)
86 return nil, ""
87 }
88
89 resp, err := http.DefaultClient.Do(req)
90 if err != nil {
91 t.Fatal(err)
92 return nil, ""
93 }
94
95 respBody, err := io.ReadAll(resp.Body)
96 if err != nil {
97 t.Fatal(err)
98 return nil, ""
99 }
100 defer resp.Body.Close()
101
102 return resp, string(respBody)
103}
104
105func testRequestNoRedirect(t *testing.T, ts *httptest.Server, method, path string, body io.Reader) (*http.Response, string) {
106 req, err := http.NewRequest(method, ts.URL+path, body)

Callers 9

TestURLFormatFunction · 0.70
TestURLFormatInSubRouterFunction · 0.70
TestGetHeadFunction · 0.70
TestStripSlashesFunction · 0.70
TestStripSlashesInRouteFunction · 0.70
TestRedirectSlashesFunction · 0.70
TestStripPrefixFunction · 0.70
TestRecovererFunction · 0.70

Calls 1

CloseMethod · 0.80

Tested by

no test coverage detected