Documentation
¶
Index ¶
- type Handle
- type Param
- type Params
- type Router
- func (router *Router) Handle(method string, path string, handle Handle)
- func (router *Router) HandleOptions(handle func(http.ResponseWriter, *http.Request))
- func (router *Router) HandlePanic(handle func(http.ResponseWriter, *http.Request, interface{}))
- func (router *Router) NotFound(handle http.HandlerFunc)
- func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (router *Router) SetValidateFn(name string, fn ValidateFn)
- type ValidateFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handle ¶
type Handle func(http.ResponseWriter, *http.Request, Params)
Handle is a function that can be registered to a route to handle HTTP requests. Like http.HandlerFunc, but has a third parameter for the values of wildcards (path variables).
type Params ¶ added in v0.7.1
type Params []Param
Params is a Param-slice, as returned by the router. The slice is ordered, the first URL parameter is also the first slice value. It is therefore safe to read values by the index.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is a http.Handler which can be used to dispatch requests to different handler functions.
func (*Router) HandleOptions ¶ added in v0.7.6
func (router *Router) HandleOptions(handle func(http.ResponseWriter, *http.Request))
HandleOptions sets a options handle.
func (*Router) HandlePanic ¶ added in v0.7.6
func (router *Router) HandlePanic(handle func(http.ResponseWriter, *http.Request, interface{}))
HandlePanic sets a panic handle.
func (*Router) NotFound ¶
func (router *Router) NotFound(handle http.HandlerFunc)
NotFound sets a NotFound handle.
func (*Router) ServeHTTP ¶
func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface.
func (*Router) SetValidateFn ¶ added in v0.9.1
func (router *Router) SetValidateFn(name string, fn ValidateFn)
SetValidateFn sets param validate function.
type ValidateFn ¶ added in v0.9.1
ValidateFn is a function to validate route params