Documentation ¶
Index ¶
- Constants
- func IsShutdown(err error) bool
- func NewRequestError(err error, status int) error
- func NewShutdownError(message string) error
- func Respond(ctx context.Context, w http.ResponseWriter, data interface{}, statusCode int) error
- func RespondError(ctx context.Context, w http.ResponseWriter, err error) error
- type App
- type Error
- type ErrorResponse
- type FieldError
- type Handler
- type Values
Constants ¶
const KeyValues ctxKey = 1
KeyValues is how request values or stored/retrieved.
Variables ¶
This section is empty.
Functions ¶
func IsShutdown ¶
IsShutdown checks to see if the shutdown error is contained in the specified error value.
func NewRequestError ¶
NewRequestError wraps a provided error with an HTTP status code. This function should be used when handlers encounter expected errors.
func NewShutdownError ¶
NewShutdownError returns an error that causes the framework to signal a graceful shutdown.
func RespondError ¶
RespondError sends an error reponse back to the client.
Types ¶
type App ¶
type App struct { *httptreemux.TreeMux // contains filtered or unexported fields }
App is the entry point
func NewApp ¶
func NewApp() *App
NewApp creates an App value that handle a set of routes for the application.
type Error ¶
type Error struct { Err error Status int Fields []FieldError }
Error is used to pass an error during the request through the application with web specific context.
type ErrorResponse ¶
type ErrorResponse struct { Error string `json:"error"` Fields []FieldError `json:"fields,omitempty"` }
ErrorResponse is the form used for API responses from failures in the API.
type FieldError ¶
FieldError is used to indicate an error with a specific request field.