Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteErrJSON ¶
func WriteErrJSON(rw http.ResponseWriter, err error, options ...ResponseOption)
WriteErrJSON writes the JSON error into given response writer.
func WriteJSON ¶
func WriteJSON(rw http.ResponseWriter, in interface{}, options ...ResponseOption)
WriteJSON writes the JSON output in given response writer.
Types ¶
type QualityValue ¶
QualityValue is the structure that contains quality - value pair.
func ParseAcceptEncodingHeader ¶
func ParseAcceptEncodingHeader(header http.Header) []QualityValue
ParseAcceptEncodingHeader parses 'Accept-Encoding' header values sorted by it's quality.
func ParseAcceptHeader ¶
func ParseAcceptHeader(header http.Header) []QualityValue
ParseAcceptHeader parses 'Accept' header values sorted by it's quality.
type ResponseOption ¶
type ResponseOption func(e *ResponseOptions)
ResponseOption is an option for the error function.
func ResponseWithContentType ¶
func ResponseWithContentType(contentType string) ResponseOption
ResponseWithContentType is an option to the http response that sets provided content type.
func ResponseWithDebug ¶ added in v0.0.28
func ResponseWithDebug(debug bool) ResponseOption
ResponseWithDebug is an option to the http response that sets provided content type.
func ResponseWithHeader ¶
func ResponseWithHeader(key, value string) ResponseOption
ResponseWithHeader is an option to the http response that sets given header with corresponding value
func ResponseWithStatus ¶
func ResponseWithStatus(status int) ResponseOption
ResponseWithStatus returns an error option that sets given response status.
type ResponseOptions ¶
ResponseOptions are the options used to customize HTTP response.
type ResponseWriter ¶
type ResponseWriter struct { Status int Buffer *bytes.Buffer Wrapped http.ResponseWriter }
ResponseWriter is a wrapper implementation for the http.ResponseWriter. It allows to have buffered writer and status. It needs to be used in a middleware so that it could manipulate the output with some compressor or react differently on panic. Look at middleware.ResponseWriter how it is used.
func WrapResponseWriter ¶
func WrapResponseWriter(rw http.ResponseWriter) *ResponseWriter
WrapResponseWriter wraps given response writer and creates an implementation that holds temporary buffer and status.
func (*ResponseWriter) Header ¶
func (r *ResponseWriter) Header() http.Header
Header implements http.ResponseWriter.
func (*ResponseWriter) Write ¶
func (r *ResponseWriter) Write(bytes []byte) (int, error)
Write implements io.Writer.
func (*ResponseWriter) WriteHeader ¶
func (r *ResponseWriter) WriteHeader(statusCode int)
WriteHeader implements http.ResponseWriter.