mux

package
v0.0.0-...-377c460 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParamsKey = ContextKey("params")
	PathKey   = ContextKey("path")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RootGroup            *Group
	NotFoundHandler      http.Handler
	CommonPrefix         string
	PathSegmentValidator func(string) bool
	GlobalMiddlewares    []Middleware
}

type ContextKey

type ContextKey string

type Endpoint

type Endpoint struct {
	Method  string
	Path    string
	Handler http.Handler
}

func NewRouter

func NewRouter(cfg *Config) (http.Handler, []*Endpoint)

type Group

type Group struct {
	Middlewares []Middleware
	Endpoints   []*Endpoint
	Subgroups   []*Group
}

func (*Group) Endpoint

func (g *Group) Endpoint(method, path string, handler http.Handler)

func (*Group) Middleware

func (g *Group) Middleware(fn func(http.Handler) http.Handler)

func (*Group) Subgroup

func (g *Group) Subgroup(fn func(g *Group))

type Middleware

type Middleware func(http.Handler) http.Handler

Jump to

Keyboard shortcuts

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