Documentation ¶
Index ¶
- Constants
- func HandlerWrapper(handler Handler) http.Handler
- func WalkRoutes(route *Route, depth int, f func(*Route, int))
- type HandleFunc
- type HandleFuncWrapper
- type Handler
- type Registrar
- type RobotListing
- type RobotsOptions
- type Route
- func (r *Route) AddGroup(group Registrar)
- func (r *Route) Any(path string, handler HandleFunc) Registrar
- func (r *Route) Delete(path string, handler HandleFunc) Registrar
- func (r *Route) Get(path string, handler HandleFunc) Registrar
- func (r *Route) Group(path string, middlewares ...func(Handler) Handler) Registrar
- func (r *Route) Handle(method, path string, handler http.Handler) Registrar
- func (r *Route) HandleFunc(method, path string, handler HandleFunc) Registrar
- func (r *Route) Head(path string, handler HandleFunc) Registrar
- func (r *Route) Match(method, path string) (bool, *Route, request.URLParams)
- func (r *Route) Options(path string, handler HandleFunc) Registrar
- func (r *Route) Patch(path string, handler HandleFunc) Registrar
- func (r *Route) Post(path string, handler HandleFunc) Registrar
- func (r *Route) Put(path string, handler HandleFunc) Registrar
- func (r *Route) Use(middlewares ...func(Handler) Handler)
- type Router
- func (r *Router) AddGroup(group Registrar)
- func (r *Router) Any(path string, handler HandleFunc) Registrar
- func (r *Router) Delete(path string, handler HandleFunc) Registrar
- func (r *Router) Get(path string, handler HandleFunc) Registrar
- func (r *Router) Group(path string, middlewares ...func(Handler) Handler) Registrar
- func (r *Router) Handle(method, path string, handler http.Handler) Registrar
- func (r *Router) HandleFunc(method, path string, handler HandleFunc) Registrar
- func (r *Router) Head(path string, handler HandleFunc) Registrar
- func (r *Router) Options(path string, handler HandleFunc) Registrar
- func (r *Router) Patch(path string, handler HandleFunc) Registrar
- func (r *Router) Post(path string, handler HandleFunc) Registrar
- func (r *Router) Put(path string, handler HandleFunc) Registrar
- func (r *Router) Robots(options *RobotsOptions) []byte
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) SiteMap() []byte
- func (r *Router) Use(middlewares ...func(Handler) Handler)
- type Vars
Constants ¶
const ( GET = "GET" POST = "POST" PUT = "PUT" DELETE = "DELETE" PATCH = "PATCH" OPTIONS = "OPTIONS" HEAD = "HEAD" // Special method for matching all methods ALL = "ALL" )
HTTP Methods
Variables ¶
This section is empty.
Functions ¶
func HandlerWrapper ¶
Wrapper function for router.Handler to make it compatible with http.handler
Types ¶
type HandleFunc ¶
HandleFunc is the function that is called when a route is matched
func HTTPWrapper ¶
func HTTPWrapper(handler func(http.ResponseWriter, *http.Request)) HandleFunc
Wrapper function for http.Handler to make it compatible with HandleFunc
type HandleFuncWrapper ¶
Wrapper function for HandleFunc to make it compatible with http.Handler
func (HandleFuncWrapper) ServeHTTP ¶
func (h HandleFuncWrapper) ServeHTTP(r *request.Request)
ServeHTTP implements the Handler interface
type Registrar ¶
type Registrar interface { Put(path string, handler HandleFunc) Registrar Post(path string, handler HandleFunc) Registrar Get(path string, handler HandleFunc) Registrar Delete(path string, handler HandleFunc) Registrar Patch(path string, handler HandleFunc) Registrar Options(path string, handler HandleFunc) Registrar Head(path string, handler HandleFunc) Registrar HandleFunc(method, path string, handler HandleFunc) Registrar Handle(method, path string, handler http.Handler) Registrar Any(path string, handler HandleFunc) Registrar Use(middlewares ...func(Handler) Handler) Group(path string, middlewares ...func(Handler) Handler) Registrar AddGroup(group Registrar) }
Registrar is the main interface for registering routes Both the router and the route struct implement this interface
type RobotListing ¶
type RobotsOptions ¶
type RobotsOptions struct { Rules []*RobotListing SiteMap string }
type Route ¶
type Route struct { Method string Path string HandlerFunc HandleFunc // contains filtered or unexported fields }
Route is a single route in the router
func (*Route) Any ¶
func (r *Route) Any(path string, handler HandleFunc) Registrar
Register a route for all methods
func (*Route) Delete ¶
func (r *Route) Delete(path string, handler HandleFunc) Registrar
Delete registers a new route with the given path and method.
func (*Route) Get ¶
func (r *Route) Get(path string, handler HandleFunc) Registrar
Get registers a new route with the given path and method.
func (*Route) HandleFunc ¶
func (r *Route) HandleFunc(method, path string, handler HandleFunc) Registrar
HandleFunc registers a new route with the given path and method.
func (*Route) Head ¶
func (r *Route) Head(path string, handler HandleFunc) Registrar
Head registers a new route with the given path and method.
func (*Route) Options ¶
func (r *Route) Options(path string, handler HandleFunc) Registrar
Options registers a new route with the given path and method.
func (*Route) Patch ¶
func (r *Route) Patch(path string, handler HandleFunc) Registrar
Patch registers a new route with the given path and method.
func (*Route) Post ¶
func (r *Route) Post(path string, handler HandleFunc) Registrar
Post registers a new route with the given path and method.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is the main router struct It takes care of dispatching requests to the correct route
func (*Router) Any ¶
func (r *Router) Any(path string, handler HandleFunc) Registrar
Register a route for all methods
func (*Router) Delete ¶
func (r *Router) Delete(path string, handler HandleFunc) Registrar
Delete registers a new route with the given path and method.
func (*Router) Get ¶
func (r *Router) Get(path string, handler HandleFunc) Registrar
Get registers a new route with the given path and method.
func (*Router) HandleFunc ¶
func (r *Router) HandleFunc(method, path string, handler HandleFunc) Registrar
HandleFunc registers a new route with the given path and method.
func (*Router) Head ¶
func (r *Router) Head(path string, handler HandleFunc) Registrar
Head registers a new route with the given path and method.
func (*Router) Options ¶
func (r *Router) Options(path string, handler HandleFunc) Registrar
Options registers a new route with the given path and method.
func (*Router) Patch ¶
func (r *Router) Patch(path string, handler HandleFunc) Registrar
Patch registers a new route with the given path and method.
func (*Router) Post ¶
func (r *Router) Post(path string, handler HandleFunc) Registrar
Post registers a new route with the given path and method.
func (*Router) Put ¶
func (r *Router) Put(path string, handler HandleFunc) Registrar
Put registers a new route with the given path and method.
func (*Router) Robots ¶
func (r *Router) Robots(options *RobotsOptions) []byte
Robots returns a ready to use robots.txt
func (*Router) ServeHTTP ¶
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP dispatches the request to the handler whose pattern matches the request URL.