Help us shape the future of Go! Take the 2026 Go Developer Survey

router

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Params

type Params map[string]string

Params holds path parameters.

type RouteID

type RouteID int

RouteID identifies a route.

type Router

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

Router matches HTTP methods and paths.

func New

func New() *Router

New creates a Router.

func (*Router) Add

func (r *Router) Add(method, pattern string) (RouteID, error)

Add registers a route and returns its id.

func (*Router) AddWithHost

func (r *Router) AddWithHost(method, host, pattern string) (RouteID, error)

AddWithHost registers a route scoped to a host (or wildcard) and returns its id.

func (*Router) Allowed

func (r *Router) Allowed(path string) []string

Allowed returns allowed methods for a given path.

func (*Router) AllowedHost

func (r *Router) AllowedHost(host, path string) []string

AllowedHost returns allowed methods for a given host/path.

func (*Router) Match

func (r *Router) Match(method, path string) (RouteID, Params, bool)

Match finds a matching route.

func (*Router) MatchHost

func (r *Router) MatchHost(method, host, path string) (RouteID, Params, bool)

MatchHost finds a matching route for a host.

Jump to

Keyboard shortcuts

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