clever

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockError

func MockError() func(http.ResponseWriter, *http.Request, map[string]string)

MockError returns a mock error response for a request.

func MockResource

func MockResource(postHandler PostHandler, filenames ...string) func(http.ResponseWriter, *http.Request, map[string]string)

MockResource returns a response with mock data from a resource file in the data/ directory.

func MockResourceID

func MockResourceID(filename string) func(http.ResponseWriter, *http.Request, map[string]string)

MockResourceID returns data for the document with a specific ID. It takes a filename and reads the corresponding file in data/, then returns the data for the object that has a matching ID, or an error if there is no object in that file with the ID.

func MockResourceRateLimit

func MockResourceRateLimit() func(http.ResponseWriter, *http.Request, map[string]string)

MockResourceRateLimit sets mock rate-limiting header values on a response.

func NewMock

func NewMock(postHandler PostHandler, dir string, lastRequestHeader ...*map[string][]string) (*http.Client, string)

NewMock loads a directory with json files representing mock resources. See ./data for an example

Types

type PostHandler

type PostHandler func(*http.Request, map[string]string) error

PostHandler is a function that handles POST requests.

Jump to

Keyboard shortcuts

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