Documentation ¶
Overview ¶
Package chirouter provides instrumentation for chi.Router.
Index ¶
- func PathToURLValues(r *http.Request) (url.Values, error)
- type Wrapper
- func (r *Wrapper) Connect(pattern string, handlerFn http.HandlerFunc)
- func (r *Wrapper) Delete(pattern string, handlerFn http.HandlerFunc)
- func (r *Wrapper) Get(pattern string, handlerFn http.HandlerFunc)
- func (r *Wrapper) Group(fn func(r chi.Router)) chi.Router
- func (r *Wrapper) Handle(pattern string, h http.Handler)
- func (r *Wrapper) Head(pattern string, handlerFn http.HandlerFunc)
- func (r *Wrapper) Method(method, pattern string, h http.Handler)
- func (r *Wrapper) MethodFunc(method, pattern string, handlerFn http.HandlerFunc)
- func (r *Wrapper) Mount(pattern string, h http.Handler)
- func (r *Wrapper) Options(pattern string, handlerFn http.HandlerFunc)
- func (r *Wrapper) Patch(pattern string, handlerFn http.HandlerFunc)
- func (r *Wrapper) Post(pattern string, handlerFn http.HandlerFunc)
- func (r *Wrapper) Put(pattern string, handlerFn http.HandlerFunc)
- func (r *Wrapper) Route(pattern string, fn func(r chi.Router)) chi.Router
- func (r *Wrapper) Trace(pattern string, handlerFn http.HandlerFunc)
- func (r *Wrapper) Use(middlewares ...func(http.Handler) http.Handler)
- func (r Wrapper) With(middlewares ...func(http.Handler) http.Handler) chi.Router
- func (r *Wrapper) Wrap(wraps ...func(handler http.Handler) http.Handler)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Wrapper ¶
type Wrapper struct { chi.Router // contains filtered or unexported fields }
Wrapper wraps chi.Router to enable unwrappable handlers in middlewares.
Middlewares can call nethttp.HandlerAs to inspect wrapped handlers.
func NewWrapper ¶
func NewWrapper(r chi.Router) *Wrapper
NewWrapper creates router wrapper to upgrade middlewares processing.
func (*Wrapper) Connect ¶
func (r *Wrapper) Connect(pattern string, handlerFn http.HandlerFunc)
Connect adds the route `pattern` that matches a CONNECT http method to execute the `handlerFn` http.HandlerFunc.
func (*Wrapper) Delete ¶
func (r *Wrapper) Delete(pattern string, handlerFn http.HandlerFunc)
Delete adds the route `pattern` that matches a DELETE http method to execute the `handlerFn` http.HandlerFunc.
func (*Wrapper) Get ¶
func (r *Wrapper) Get(pattern string, handlerFn http.HandlerFunc)
Get adds the route `pattern` that matches a GET http method to execute the `handlerFn` http.HandlerFunc.
func (*Wrapper) Group ¶
func (r *Wrapper) Group(fn func(r chi.Router)) chi.Router
Group adds a new inline-router along the current routing path, with a fresh middleware stack for the inline-router.
func (*Wrapper) Head ¶
func (r *Wrapper) Head(pattern string, handlerFn http.HandlerFunc)
Head adds the route `pattern` that matches a HEAD http method to execute the `handlerFn` http.HandlerFunc.
func (*Wrapper) Method ¶
Method adds routes for `basePattern` that matches the `method` HTTP method.
func (*Wrapper) MethodFunc ¶
func (r *Wrapper) MethodFunc(method, pattern string, handlerFn http.HandlerFunc)
MethodFunc adds the route `pattern` that matches `method` http method to execute the `handlerFn` http.HandlerFunc.
func (*Wrapper) Options ¶
func (r *Wrapper) Options(pattern string, handlerFn http.HandlerFunc)
Options adds the route `pattern` that matches a OPTIONS http method to execute the `handlerFn` http.HandlerFunc.
func (*Wrapper) Patch ¶
func (r *Wrapper) Patch(pattern string, handlerFn http.HandlerFunc)
Patch adds the route `pattern` that matches a PATCH http method to execute the `handlerFn` http.HandlerFunc.
func (*Wrapper) Post ¶
func (r *Wrapper) Post(pattern string, handlerFn http.HandlerFunc)
Post adds the route `pattern` that matches a POST http method to execute the `handlerFn` http.HandlerFunc.
func (*Wrapper) Put ¶
func (r *Wrapper) Put(pattern string, handlerFn http.HandlerFunc)
Put adds the route `pattern` that matches a PUT http method to execute the `handlerFn` http.HandlerFunc.
func (*Wrapper) Trace ¶
func (r *Wrapper) Trace(pattern string, handlerFn http.HandlerFunc)
Trace adds the route `pattern` that matches a TRACE http method to execute the `handlerFn` http.HandlerFunc.
func (*Wrapper) Wrap ¶ added in v0.2.28
Wrap appends one or more wrappers that will be applied to handler before adding to Router. It is different from middleware in the sense that it is handler-centric, rather than request-centric. Wraps are invoked once for each added handler, they are not invoked for http requests. Wraps can leverage nethttp.HandlerAs to inspect and access deeper layers. For most cases Wrap can be safely used instead of Use, Use is mandatory for middlewares that affect routing (such as middleware.StripSlashes for example).