helper

package
v2.7.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package helper provides helpers for the development and testing of middleware wrappers.

Index

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

func JSONRequest(ptr interface{}, r *http.Request) (err error)

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.

Jump to

Keyboard shortcuts

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