Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteJSONResponse ¶
func WriteJSONResponse(w http.ResponseWriter, data interface{}, code int, logger log.Logger)
WriteJSONResponse marshals the provided data to a JSON string and writes the data to the http.ResponseWriter
func WriteResponse ¶
WriteResponse writes a response to http.ResponseWriter, handling and logging any errors that may occur.
Types ¶
type ResponseWrapper ¶ added in v0.4.0
type ResponseWrapper interface { // Header returns the stored http.Header Header() http.Header // ResponseWriter returns this interface as a http.ResponseWriter // This is a convenience function only ResponseWriter() http.ResponseWriter // Status returns the written status code Status() int // Write simulates writing data to the writer and returns the predetermined error and write count Write([]byte) (int, error) // WriteHeader stores the statusCode to be returned for later checking with `ResponseWriter.Status` WriteHeader(statusCode int) }
ResponseWrapper is an interface that wraps an `http.ResponseWriter`, allowing for information to be retrieved for logging or to be used in testing
func NewResponseWrapper ¶ added in v0.4.0
func NewResponseWrapper(w http.ResponseWriter) ResponseWrapper
NewResponseWrapper returns a new ResponseWrapper that internally stores the provided http.ResponseWriter
Click to show internal directories.
Click to hide internal directories.