Documentation ¶
Index ¶
- func PlainTextErrorHandler(res http.ResponseWriter, err interface{})
- func SimpleHTMLErrorHandler(res http.ResponseWriter, err interface{})
- type ErrorHandler
- type ExtendedResponse
- func NewHTMLResponse(status int) ExtendedResponse
- func NewJSONResponse(status int, data interface{}) ExtendedResponse
- func NewPlainTextResponse(status int) ExtendedResponse
- func NewRedirectResponse(permanent bool, location string) ExtendedResponse
- func NewResponse(status int, contentType string, isText bool) ExtendedResponse
- type HandlerBuilder
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PlainTextErrorHandler ¶
func PlainTextErrorHandler(res http.ResponseWriter, err interface{})
PlainTextErrorHandler writes the error message as plain text to the HTTP response
func SimpleHTMLErrorHandler ¶
func SimpleHTMLErrorHandler(res http.ResponseWriter, err interface{})
SimpleHTMLErrorHandler writes the error message as simple HTML to the HTTP response
Types ¶
type ErrorHandler ¶
type ErrorHandler func(http.ResponseWriter, interface{})
An ErrorHandler takes a http.ResponseWriter and any error values and writes its error message to the ResponseWriter
type ExtendedResponse ¶
type ExtendedResponse interface { Response io.Writer // Append data to the content SetHeader(string, string) DisableCaching() AllowCompression(*http.Request) }
ExtendedResponse is a extension of the Response interface which adds some comfort functions and extended Features
func NewHTMLResponse ¶
func NewHTMLResponse(status int) ExtendedResponse
NewHTMLResponse returns a new HTML response with the given status code
func NewJSONResponse ¶
func NewJSONResponse(status int, data interface{}) ExtendedResponse
NewJSONResponse returns a new JSON response with the given status code and content
func NewPlainTextResponse ¶
func NewPlainTextResponse(status int) ExtendedResponse
NewPlainTextResponse returns a new Plaintext response with the given status code
func NewRedirectResponse ¶
func NewRedirectResponse(permanent bool, location string) ExtendedResponse
NewRedirectResponse returns a new Redirect Response
func NewResponse ¶
func NewResponse(status int, contentType string, isText bool) ExtendedResponse
NewResponse returns a new Response with the given values
type HandlerBuilder ¶
type HandlerBuilder struct {
ErrorHandler ErrorHandler
}
The HandlerBuilder is used to set the default values for new instances of http.Handler
func (*HandlerBuilder) NewHandler ¶
NewHandler returns a new generic HTTP handler
type Response ¶
type Response interface {
WriteResponse(http.ResponseWriter) error
}
Response represents a (before calling WriteResponse non-sent) HTTP response returned by the handler function.
func Handle404Plain ¶
Handle404Plain returns a plain text answer for the 404 error
func Handle404SimpleHTML ¶
Handle404SimpleHTML returns a simple HTML answer for the 404 error