Documentation
¶
Overview ¶
Package api provides standard API request/response handling.
Index ¶
Constants ¶
const HeaderAPIVersion = `X-Api-Version`
HeaderAPIVersion is the canonical name of the HTTP header key that reports the API version.
Variables ¶
This section is empty.
Functions ¶
Types ¶
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 ¶
type ErrorResponse struct { Error struct { Message string `json:"message"` RequestID string `json:"request_id,omitempty"` } `json:"error"` }
ErrorResponse is the body of an Error served up by Err
type Option ¶
type Option func(w http.ResponseWriter)
Option functions provide a means for manipulating things like adding additional headers to responses.
type Responder ¶
type Responder struct {
// contains filtered or unexported fields
}
Responder writes API responses. nil Responder is safe to use.
func NewResponder ¶
NewResponder makes a new Responder object.
func (*Responder) Err ¶
Err responds with an error that corresponds to the behavior the type is illustrating.