Documentation
¶
Index ¶
- func Decode(r *http.Request, v interface{}) error
- type ClientIPFunc
- type Conflicter
- type Counter
- type ErrJSON
- type ErrValidationFailed
- type ErrorData
- type ErrorResponse
- type Exister
- type HTTP
- type HTTPErr
- type NotFounder
- type OK
- type RequestIDFunc
- type Responder
- type ResponderOption
- type UserMessager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClientIPFunc ¶
ClientIPFunc is a function that can be used to retrieve the client IP from a context.
type Conflicter ¶
type Conflicter interface {
Conflict() bool
}
Conflicter determines if an error exhibits the behavior of a conflict err. This corresponds to times when you receive unexpected errors or an error of high severity.
type Counter ¶ added in v0.0.5
type Counter interface {
Inc()
}
Counter is a metric for counting the number of occurances of an event.
type ErrJSON ¶
type ErrJSON struct {
// contains filtered or unexported fields
}
ErrJSON error is returned by Decode when the incoming JSON unmarshaling fails.
func (*ErrJSON) StatusCode ¶
StatusCode returns the http status code that would refer to json payload that fails to decode error.
type ErrValidationFailed ¶
type ErrValidationFailed struct {
// contains filtered or unexported fields
}
ErrValidationFailed is returned by Decode if the object is not valid.
func (*ErrValidationFailed) Error ¶
func (e *ErrValidationFailed) Error() string
Error reports the error string.
func (*ErrValidationFailed) StatusCode ¶
func (e *ErrValidationFailed) StatusCode() int
StatusCode returns the http status code that would refer to a validation error.
type ErrorResponse ¶
ErrorResponse is the body of an Error served up by Err
type Exister ¶
type Exister interface {
Exists() bool
}
Exister determines if an error exhibits the behavior of a resource already exists err.
type HTTP ¶
type HTTP interface {
StatusCode() int
}
HTTP determines if an error exhibits the behavior of an error that provides an HTTP status code and the error message itself is safe for returning to a client.
type HTTPErr ¶
type HTTPErr struct {
Code int
// contains filtered or unexported fields
}
HTTPErr is a error that provides a status code.
func (*HTTPErr) StatusCode ¶
StatusCode provides the status code associated with the error message.
type NotFounder ¶
type NotFounder interface {
NotFound() bool
}
NotFounder determines if an error exhibits the behavior of a resource not found err.
type RequestIDFunc ¶
RequestIDFunc is a function that can be used to retrieve the request ID from a context.
type Responder ¶
type Responder struct {
// contains filtered or unexported fields
}
Responder writes API responses.
func NewResponder ¶
func NewResponder(logger *logger.L, opts ...ResponderOption) *Responder
NewResponder makes a new Responder object.
func (*Responder) Err ¶
Err responds with an error that corresponds to the behavior the type is illustrating.
type ResponderOption ¶
type ResponderOption func(*options)
ResponderOption is used to customize the API responder.
func WithClientIPFunc ¶
func WithClientIPFunc(fn ClientIPFunc) ResponderOption
WithClientIPFunc sets the function to retrieve the client IP.
func WithCounterPanics ¶ added in v0.0.5
func WithCounterPanics(c Counter) ResponderOption
WithCounterPanics will use the Counter to track any recovered panics.
func WithLogResponseBodies ¶
func WithLogResponseBodies(enabled bool) ResponderOption
WithLogResponseBodies enables the logging of response bodies.
func WithRequestIDFunc ¶
func WithRequestIDFunc(fn RequestIDFunc) ResponderOption
WithRequestIDFunc sets the function to retrieve the request ID.
type UserMessager ¶ added in v0.0.3
type UserMessager interface {
UserMessage() string
}
UserMessager can be used to present a specific message to the user.