Documentation ¶
Overview ¶
Package router routes requests
Index ¶
Constants ¶
View Source
const ErrInvalidRequest = errors.Code("invalid_request")
ErrInvalidRequest is returned when the request is not valid
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface { Request() *http.Request Writer() http.ResponseWriter PathParams() httprouter.Params Get(string) interface{} Set(string, interface{}) Empty(int) error JSON(int, interface{}) error Bind(out interface{}, validators ...Validator) error BindQuery(out interface{}, validators ...Validator) error }
Context holds data about the request and provides convenience methods for responding
func NewContext ¶
func NewContext(request *http.Request, rw http.ResponseWriter, p httprouter.Params) Context
NewContext creates a new context
type Router ¶
type Router struct { // Middlewares that are applied to all routes, before a route's middleware Middlewares []Middleware // Translator is used to translate error messages returned by the Routes Translator errors.Translator // contains filtered or unexported fields }
Router wraps an http router
func (*Router) Add ¶
func (r *Router) Add(path string, route interface{}, middlewares ...Middleware)
Add registers a route with the router
The global middlewares that will be used are the ones currently set with the Router instance Changing them later on will not affect the route
Click to show internal directories.
Click to hide internal directories.