routing

package
v0.0.0-...-9518a5e Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: MIT 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" mapstructure:"provider" toml:"provider,omitempty"`
	AllowedOrigins []string `json:"allowed_origins" mapstructure:"allowed_origins" toml:"allowed_origins,omitempty"`
	AllowedHeaders []string `json:"allowed_heade" mapstructure:"allowed_headers" toml:"allowed_headers,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