Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResponseRecorder ¶
type ResponseRecorder struct { // Code is the HTTP response code set at initialization. Code int // HeaderMap contains the headers explicitly set by the Handler. // It is an internal detail. HeaderMap pkgHTTP.Header // body is the buffer to which the Handler's Write calls are sent. // If nil, the Writes are silently discarded. Body *bytes.Buffer // contains filtered or unexported fields }
ResponseRecorder is an implementation of pkgHTTP.Response that records its mutations for later inspection in tests.
func NewRecorder ¶
func NewRecorder() *ResponseRecorder
NewRecorder returns an initialized ResponseRecorder.
func (*ResponseRecorder) Header ¶
func (rw *ResponseRecorder) Header() pkgHTTP.Header
Header implements pkgHTTP.Response. It returns the response headers to mutate within a handler.
func (*ResponseRecorder) StatusCode ¶
func (rw *ResponseRecorder) StatusCode() int
StatusCode returns the response code.
Note that if a Handler never calls WriteHeader, this will be initial status code, rather than the implicit http.StatusOK.
func (*ResponseRecorder) Write ¶
func (rw *ResponseRecorder) Write(buf []byte) (int, error)
Write implements pkgHTTP.Response. The data in buf is written to rw.Body, if not nil.
func (*ResponseRecorder) WriteHeader ¶
func (rw *ResponseRecorder) WriteHeader(code int)
WriteHeader implements pkgHTTP.Response. The statusCode is only allowed to be written once.
Click to show internal directories.
Click to hide internal directories.