Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Path ¶ added in v0.2.0
type Path struct { // Methods defines which HTTP methods should be accepted. If the request doesn't match, TestServer returns HTTP 405. // If Methods is empty, all HTTP methods are accepted. Methods []string // StatusCode tells TestServer what HTTP status code to return for matching requests. // If StatusCode is 0, TestServer returns HTTP 200. StatusCode int // Body is the body that TestServer will return for the Path. Body []byte }
Path defines how TestServer should reply to a request.
type TestServer ¶ added in v0.2.0
TestServer is a dummy http.Handler that can be used to create a httptest.Server. TestServer serves HTTP requests, using Path to determine how to reply, where the key is matched again r.URL.Path. If no Path matches the request, TestServer returns HTTP 404
func (*TestServer) Calls ¶ added in v0.2.0
func (t *TestServer) Calls() map[string]int
Calls returns how many requests were accepted for each path.
func (*TestServer) ServeHTTP ¶ added in v0.2.0
func (t *TestServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*TestServer) TotalCalls ¶ added in v0.2.0
func (t *TestServer) TotalCalls() int
TotalCalls returns how many requests were accepted for all paths.
Click to show internal directories.
Click to hide internal directories.