httpmock

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2017 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PathHandler

func PathHandler(t *testing.T, reqPath string, respStatus int, respBody string) http.Handler

PathHandler will fail if the request doesn't match based on reqPath. If it matches it returns the given response status and body.

reqPath should be of the form `<METHOD> <PATH>`. For example: `GET /foo`.

Types

type ServeReplay

type ServeReplay struct {
	Handlers     []http.Handler
	NoneLeftFunc func(*testing.T, *http.Request)
	// contains filtered or unexported fields
}

ServeReplay is an http.Handler It contains a list of handlers and calls the next handler in the list for each incoming request.

If a request is received and no more handlers are available, ServeReplay calls NoneLeftFunc. The default behavior of NoneLeftFunc is to call t.Errorf with some information about the request.

func NewServeReplay

func NewServeReplay(t *testing.T) *ServeReplay

NewServeReplay returns a new ServeReplay.

func (*ServeReplay) Add

func (h *ServeReplay) Add(handler http.Handler) *ServeReplay

Add appends a handler to ServReplay's handler list. It returns itself to allow chaining.

func (*ServeReplay) ServeHTTP

func (h *ServeReplay) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP dispatches the request to the next handler in the list.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL