router

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateName = errors.New("coyote/router: duplicate route name")
	ErrUnknownName   = errors.New("coyote/router: no route with that name")
	ErrWrongArity    = errors.New("coyote/router: wrong number of values for route")
)

Functions

func Chain

func Chain(h http.Handler, mw ...Middleware) http.Handler

Types

type Middleware

type Middleware func(http.Handler) http.Handler

type Route

type Route struct {
	Method  string
	Pattern string
	Name    string
	// contains filtered or unexported fields
}

func (Route) Fill

func (route Route) Fill(values ...any) (string, error)

func (*Route) Named

func (route *Route) Named(name string) *Route

func (Route) Wildcards

func (route Route) Wildcards() []string

type Router

type Router struct {
	// contains filtered or unexported fields
}

func New

func New() *Router

func (*Router) Any

func (r *Router) Any(pattern string, fn http.HandlerFunc, mw ...Middleware) *Route

func (*Router) Delete

func (r *Router) Delete(pattern string, fn http.HandlerFunc, mw ...Middleware) *Route

func (*Router) Get

func (r *Router) Get(pattern string, fn http.HandlerFunc, mw ...Middleware) *Route

func (*Router) Group

func (r *Router) Group(prefix string, mw ...Middleware) *Router

func (*Router) Handle

func (r *Router) Handle(method, pattern string, h http.Handler, mw ...Middleware) *Route

func (*Router) HandleFunc

func (r *Router) HandleFunc(method, pattern string, fn http.HandlerFunc, mw ...Middleware) *Route

func (*Router) Mount

func (r *Router) Mount(prefix string, h http.Handler, mw ...Middleware) *Route

func (*Router) MustReverse

func (r *Router) MustReverse(name string, values ...any) string

func (*Router) Named

func (r *Router) Named(name string) (Route, bool)

func (*Router) NotFound

func (r *Router) NotFound() http.Handler

func (*Router) Patch

func (r *Router) Patch(pattern string, fn http.HandlerFunc, mw ...Middleware) *Route

func (*Router) Post

func (r *Router) Post(pattern string, fn http.HandlerFunc, mw ...Middleware) *Route

func (*Router) Put

func (r *Router) Put(pattern string, fn http.HandlerFunc, mw ...Middleware) *Route

func (*Router) Reverse

func (r *Router) Reverse(name string, values ...any) (string, error)

func (*Router) Routes

func (r *Router) Routes() []Route

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Router) SetNotFound

func (r *Router) SetNotFound(handler http.Handler)

func (*Router) Static

func (r *Router) Static(prefix string, fsys fs.FS) *Route

func (*Router) Use

func (r *Router) Use(mw ...Middleware)

Jump to

Keyboard shortcuts

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