routing

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package routing provides HTTP routing abstractions including router, middleware, and route parameter interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextKey

type ContextKey string

ContextKey represents strings to be used in Context objects. From the docs:

"The provided key must be comparable and should not be of type string or
 any other built-in type to avoid collisions between packages using context."

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware is a type alias for a middleware handler function.

type Route

type Route struct {
	Method string
	Path   string
}

Route represents a registered HTTP route with its method and path.

type RouteParamManager

type RouteParamManager interface {
	BuildRouteParamIDFetcher(logger logging.Logger, key, logDescription string) func(req *http.Request) uint64
	BuildRouteParamStringIDFetcher(key string) func(req *http.Request) string
}

RouteParamManager builds route param fetchers for a compatible router.

type Router

type Router interface {
	Routes() []*Route
	Handler() http.Handler
	Handle(pattern string, handler http.Handler)
	HandleFunc(pattern string, handler http.HandlerFunc)
	WithMiddleware(middleware ...Middleware) Router
	Route(pattern string, fn func(r Router)) Router
	Connect(pattern string, handler http.HandlerFunc)
	Delete(pattern string, handler http.HandlerFunc)
	Get(pattern string, handler http.HandlerFunc)
	Head(pattern string, handler http.HandlerFunc)
	Options(pattern string, handler http.HandlerFunc)
	Patch(pattern string, handler http.HandlerFunc)
	Post(pattern string, handler http.HandlerFunc)
	Put(pattern string, handler http.HandlerFunc)
	Trace(pattern string, handler http.HandlerFunc)
	AddRoute(method, path string, handler http.HandlerFunc, middleware ...Middleware) error
}

Router defines the contract between routing library and caller.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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