makeRequest builds and executes an HTTP request against this server. Optional headers are applied after the default Content-Type.
(t *testing.T, method string, path string, body []byte, header ...http.Header)
| 64 | // makeRequest builds and executes an HTTP request against this server. |
| 65 | // Optional headers are applied after the default Content-Type. |
| 66 | func (s *bridgeTestServer) makeRequest(t *testing.T, method string, path string, body []byte, header ...http.Header) (*http.Response, error) { |
| 67 | t.Helper() |
| 68 | |
| 69 | req, err := http.NewRequestWithContext(t.Context(), method, s.URL+path, bytes.NewReader(body)) |
| 70 | if err != nil { |
| 71 | return nil, err |
| 72 | } |
| 73 | req.Header.Set("Content-Type", "application/json") |
| 74 | for _, h := range header { |
| 75 | for k, vals := range h { |
| 76 | for _, v := range vals { |
| 77 | req.Header.Add(k, v) |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | return http.DefaultClient.Do(req) |
| 82 | } |
| 83 | |
| 84 | type bridgeOption func(*bridgeConfig) |
| 85 |