MCPcopy
hub / github.com/dghubble/gologin / NewErrorServer

Function NewErrorServer

testutils/server.go:27–33  ·  view source on GitHub ↗

NewErrorServer returns a new httptest.Server, which responds with the given error message and code, and a client which proxies requests to the server using a custom transport. The caller must close the server.

(message string, code int)

Source from the content-addressed store, hash-verified

25// error message and code, and a client which proxies requests to the server
26// using a custom transport. The caller must close the server.
27func NewErrorServer(message string, code int) (*http.Client, *httptest.Server) {
28 client, mux, server := TestServer()
29 mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
30 http.Error(w, message, code)
31 })
32 return client, server
33}
34
35// NewTestServerFunc is an adapter to allow the use of ordinary functions as
36// httptest.Server's for testing. Caller must close the server.

Calls 1

TestServerFunction · 0.85