routing

package
v0.0.0-...-98cd694 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Unlicense Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ChiProvider is the string we use to refer to chi.
	ChiProvider = "chi"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Provider               string `json:"provider,omitempty"            toml:"provider,omitempty"`
	EnableCORSForLocalhost bool   `json:"enableCORSForLocalhost"        toml:"enable_cors_for_localhost"`
	SilenceRouteLogging    bool   `json:"silenceRouteLogging,omitempty" toml:"silence_route_logging,omitempty"`
	// contains filtered or unexported fields
}

Config configures our router.

func (*Config) ValidateWithContext

func (cfg *Config) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates a router config struct.

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware is a type alias for a middleware handler function.

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 {
	LogRoutes()
	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