Documentation
¶
Overview ¶
Library respond creates convreq.HttpResponse objects. These can be returned from HTTP handlers to respond something to the client.
Index ¶
- func BadRequest(msg string) internal.HttpResponse
- func Error(err error) internal.HttpResponse
- func Handler(h http.Handler) internal.HttpResponse
- func InternalServerError(msg string) internal.HttpResponse
- func NotFound(msg string) internal.HttpResponse
- func OverrideResponseCode(hr internal.HttpResponse, code int) internal.HttpResponse
- func PermissionDenied(msg string) internal.HttpResponse
- func Printf(format string, v ...interface{}) internal.HttpResponse
- func Reader(r io.Reader) internal.HttpResponse
- func Redirect(code int, url string) internal.HttpResponse
- func RenderTemplate(tpl Template, data interface{}) internal.HttpResponse
- func String(data string) internal.HttpResponse
- func WithHeader(hr internal.HttpResponse, header, value string) internal.HttpResponse
- func WithHeaders(hr internal.HttpResponse, headers http.Header) internal.HttpResponse
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
func BadRequest(msg string) internal.HttpResponse
BadRequest creates a HTTP 400 Bad Request response.
func Error ¶
func Error(err error) internal.HttpResponse
Error creates a HTTP 500 Internal Server Error response.
func Handler ¶
func Handler(h http.Handler) internal.HttpResponse
Handler creates a response that delegates to a regular http.Handler.
func InternalServerError ¶
func InternalServerError(msg string) internal.HttpResponse
InternalServerError creates a HTTP 500 Internal Server Error response.
func NotFound ¶
func NotFound(msg string) internal.HttpResponse
NotFound creates a HTTP 404 Not Found response.
func OverrideResponseCode ¶
func OverrideResponseCode(hr internal.HttpResponse, code int) internal.HttpResponse
OverrideResponseCode wraps a response to override the status code with the one given to this function. Note that this replaces the original ResponseWriter with an internal one, possibly not implementing interfaces like Flusher.
func PermissionDenied ¶
func PermissionDenied(msg string) internal.HttpResponse
PermissionDenied creates a HTTP 403 Permission Denied response.
func Printf ¶
func Printf(format string, v ...interface{}) internal.HttpResponse
Printf creates a response that sends a formatted string back to the client.
func Reader ¶
func Reader(r io.Reader) internal.HttpResponse
Reader creates a response that copies everything from the reader to the client.
func Redirect ¶
func Redirect(code int, url string) internal.HttpResponse
Redirect creates a response that redirects to another URL.
func RenderTemplate ¶
func RenderTemplate(tpl Template, data interface{}) internal.HttpResponse
RenderTemplate creates a response that will render the given template.
func String ¶
func String(data string) internal.HttpResponse
String creates a response that sends a string back to the client.
func WithHeader ¶
func WithHeader(hr internal.HttpResponse, header, value string) internal.HttpResponse
WithHeader wraps a response and adds an additional header to be set.
func WithHeaders ¶
func WithHeaders(hr internal.HttpResponse, headers http.Header) internal.HttpResponse
WithHeaders wraps a response and adds additional headers to be set.