Documentation
¶
Overview ¶
Package router provides a basic HTTP-router which wraps http.ServerMux.
Index ¶
- type Router
- func (r *Router) Handle(pattern string, handler http.Handler)
- func (r *Router) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
- func (r *Router) Handler() http.Handler
- func (r *Router) New(prefix string) *Router
- func (r *Router) Use(middelware func(http.Handler) http.Handler)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is similar to http.ServeMux, except is allows registering middleware and creating "sub" routers.
Handler-patterns support the same features and syntax as http.ServeMux.
func (*Router) Handle ¶
Handle registers a handler for a pattern. Patterns support the same syntax as http.ServerMux.
func (*Router) HandleFunc ¶
HandleFunc registers a handler for a pattern. Patterns support the same syntax as http.ServerMux.
func (*Router) Handler ¶
Handler produces an http.Handler to server requests using the handlers and middleware registered to the router.
func (*Router) New ¶
New creates a sub-router. All handlers registered to the sub-router will use the parent router's middleware. All handlers registered to the sub-router will be scoped to the passed-in path-prefix (which may be empty).
All parent-middleware will be applied before all sub-router middleware.