Documentation
¶
Overview ¶
Package helper provides helpers for the development and testing of middleware wrappers.
Index ¶
- func AssertHeader(rec *httptest.ResponseRecorder, key, val string) error
- func AssertResponse(rec *httptest.ResponseRecorder, body string, code int) error
- func JSONRequest(ptr interface{}, r *http.Request) (err error)
- func JSONResponse(obj interface{}, w http.ResponseWriter) (err error)
- func NewTestRequest(method, path string) (recorder *httptest.ResponseRecorder, request *http.Request)
- func WriteError(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertHeader ¶
func AssertHeader(rec *httptest.ResponseRecorder, key, val string) error
AssertHeader checks, if the ResponseRecorder has a header of key with the value val. If it has not, an error is returned.
func AssertResponse ¶
func AssertResponse(rec *httptest.ResponseRecorder, body string, code int) error
AssertResponse checks if the given body and code matches the response recorder. If one of them do not match, an error is returned
func JSONRequest ¶
JSONRequest unmarshals the http.Request body to the object of the pointer ptr
func JSONResponse ¶
func JSONResponse(obj interface{}, w http.ResponseWriter) (err error)
JSONResponse mashals the given obj to the given http.ResponseWriter
func NewTestRequest ¶
func NewTestRequest(method, path string) (recorder *httptest.ResponseRecorder, request *http.Request)
NewTestRequest creates a testing request and a response recorder
func WriteError ¶
func WriteError(w http.ResponseWriter, r *http.Request)
WriteError writes a simple 500 internal server error
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.