Documentation ¶
Overview ¶
Package happier contains http REST API errors that are compatible with horror handlers.
Index ¶
- func Accepted(w http.ResponseWriter, r *http.Request) horror.Error
- func Created(w http.ResponseWriter, r *http.Request, payload interface{}) horror.Error
- func NoContent(w http.ResponseWriter, r *http.Request) horror.Error
- func OK(w http.ResponseWriter, r *http.Request, payload interface{}) horror.Error
- func SeeOther(w http.ResponseWriter, r *http.Request, url string) horror.Error
- type Adapter
- type Factory
- func (f *Factory) BadRequest(err error, message string) horror.Error
- func (f *Factory) Conflict(err error, message string) horror.Error
- func (f *Factory) InternalServerError(err error, message string) horror.Error
- func (f *Factory) NotFound(err error, message string) horror.Error
- func (f *Factory) Unauthorized(err error, message string) horror.Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Created ¶
Created outputs given payload to http client with http status created.
If json package fails to marshal given payload, Created returns internal server error.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter adapts horror Handlers for usage with chi router, because it accepts only HandlerFuncs to its routing methods along `pattern`.
Use NewAdapter as constructor if you want to use Adapter.
func NewAdapter ¶
func NewAdapter() *Adapter
NewAdapter is the only proper constructor for Adapter type.
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory contains method for declaring http oriented errors.
func Default ¶
func Default() *Factory
Default returns default error factory not associated with any http request.
func FromContext ¶
FromContext returns factory that should be used only within given context range.
func FromRequest ¶
FromRequest returns factory that should be used only with given http request.
func (*Factory) BadRequest ¶
BadRequest implements http bad request (400) error for horror.Error interface to use in long-season REST API.
func (*Factory) Conflict ¶
Conflict implements http conflict (409) error for horror.Error interface to use in long-season REST API.
func (*Factory) InternalServerError ¶
InternalServerError implements http internal server error (500) for horror.Error interface to use in long-season REST API.