chirouter

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package chirouter provides instrumentation for chi.Router.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PathToURLValues

func PathToURLValues(rc *fasthttp.RequestCtx, params url.Values) error

PathToURLValues is a decoder function for parameters in path.

Types

type Wrapper

type Wrapper struct {
	fchi.Router
	// contains filtered or unexported fields
}

Wrapper wraps chi.Router to enable unwrappable handlers in middlewares.

Middlewares can call fhttp.HandlerAs to inspect wrapped handlers.

func NewWrapper

func NewWrapper(r fchi.Router) *Wrapper

NewWrapper creates router wrapper to upgrade middlewares processing.

func (*Wrapper) Connect

func (r *Wrapper) Connect(pattern string, h fchi.Handler)

Connect adds the route `pattern` that matches a CONNECT http method to execute the `h` fchi.Handler.

func (*Wrapper) Delete

func (r *Wrapper) Delete(pattern string, h fchi.Handler)

Delete adds the route `pattern` that matches a DELETE http method to execute the `h` fchi.Handler.

func (*Wrapper) Get

func (r *Wrapper) Get(pattern string, h fchi.Handler)

Get adds the route `pattern` that matches a GET http method to execute the `h` fchi.Handler.

func (*Wrapper) Group

func (r *Wrapper) Group(fn func(r fchi.Router)) fchi.Router

Group adds a new inline-router along the current routing path, with a fresh middleware stack for the inline-router.

func (*Wrapper) Handle

func (r *Wrapper) Handle(pattern string, h fchi.Handler)

Handle adds routes for `basePattern` that matches all HTTP methods.

func (*Wrapper) Head

func (r *Wrapper) Head(pattern string, h fchi.Handler)

Head adds the route `pattern` that matches a HEAD http method to execute the `h` fchi.Handler.

func (*Wrapper) Method

func (r *Wrapper) Method(method, pattern string, h fchi.Handler)

Method adds routes for `basePattern` that matches the `method` HTTP method.

func (*Wrapper) Mount

func (r *Wrapper) Mount(pattern string, h fchi.Handler)

Mount attaches another Handler along "./basePattern/*".

func (*Wrapper) Options

func (r *Wrapper) Options(pattern string, h fchi.Handler)

Options adds the route `pattern` that matches a OPTIONS http method to execute the `h` fchi.Handler.

func (*Wrapper) Patch

func (r *Wrapper) Patch(pattern string, h fchi.Handler)

Patch adds the route `pattern` that matches a PATCH http method to execute the `h` fchi.Handler.

func (*Wrapper) Post

func (r *Wrapper) Post(pattern string, h fchi.Handler)

Post adds the route `pattern` that matches a POST http method to execute the `h` fchi.Handler.

func (*Wrapper) Put

func (r *Wrapper) Put(pattern string, h fchi.Handler)

Put adds the route `pattern` that matches a PUT http method to execute the `h` fchi.Handler.

func (*Wrapper) Route

func (r *Wrapper) Route(pattern string, fn func(r fchi.Router)) fchi.Router

Route mounts a sub-router along a `basePattern` string.

func (*Wrapper) Trace

func (r *Wrapper) Trace(pattern string, h fchi.Handler)

Trace adds the route `pattern` that matches a TRACE http method to execute the `h` fchi.Handler.

func (*Wrapper) Use

func (r *Wrapper) Use(middlewares ...func(fchi.Handler) fchi.Handler)

Use appends one of more middlewares onto the Router stack.

func (Wrapper) With

func (r Wrapper) With(middlewares ...func(fchi.Handler) fchi.Handler) fchi.Router

With adds inline middlewares for an endpoint handler.

func (*Wrapper) Wrap

func (r *Wrapper) Wrap(wraps ...func(handler fchi.Handler) fchi.Handler)

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 fhttp.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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL