Documentation ¶
Overview ¶
Package web aids in writing HTTP servers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewError ¶
NewError constructs a NewApiError with the supplied HTTP Status Code and formats the supplied msg & arguments
func Write ¶
func Write(w http.ResponseWriter, vals ...interface{})
Write is a helper function to write out a http response. It'll write the first non-nil val in the val list (so you can do things like web.Write(w, err, foo)) and have err returned if it was set.
func WriteError ¶
func WriteError(w http.ResponseWriter, statusCode int, formatMsg string, params ...interface{})
WriteError will write a textual error response to the supplied ResponseWriter with the supplied HTTP StatusCode
Types ¶
type APIError ¶
type APIError struct {
// contains filtered or unexported fields
}
APIError defines an error that is destined to be a HTTP response. It includes both a textual message and HTTP Status Code to use. Construct an APIError using NewError.
func (*APIError) HTTPWrite ¶
func (a *APIError) HTTPWrite(w http.ResponseWriter)
HTTPWrite can be called to return this error as a HTTP Response
type HTTPWriter ¶
type HTTPWriter interface {
HTTPWrite(w http.ResponseWriter)
}
HTTPWriter defines a way for a type to control how its returned as a HTTP response values passed to Write that implement this interface will have their HTTPWrite function called to generate the HTTP Response