Documentation
¶
Index ¶
- func HandlerFunc(fn http.HandlerFunc) *httptest.Server
- func JSON(code int, body interface{}) (*httptest.Server, error)
- func Simple(code int, contentType, body string) *httptest.Server
- func WithRoutes(rtes []Route) *httptest.Server
- func XML(code int, body interface{}) (*httptest.Server, error)
- type Route
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandlerFunc ¶
func HandlerFunc(fn http.HandlerFunc) *httptest.Server
HandlerFunc takes a http.HandlerFunc instead of a body so you can do whatever that you would like and take full control
func JSON ¶
JSON does a little more magic, where it takes a code and interface{}. It will set the content-type to application/json for you and marshal the object for the test server
func Simple ¶
Simple does little to no setup for you just takes status code, content-type and the body
func WithRoutes ¶
WithRoutes creates a new mockserver that takes an array of routes and puts them into a httptest.Server
Types ¶
type Route ¶
type Route struct { Method string Path string Handle httprouter.Handle }
Route is common structure for setting up routes with the mockserver
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template is exported for the sake of name collision and name spacing.
func NewTemplate ¶
NewTemplate sets up test/template. It is if you want to dynamically populate your response. The base just is the text/template syntax