router

package
v0.3.14 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(path string, ps trie.Params)

type Router

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

Router is a Handler which can be used to dispatch requests to different handler functions via configurable routes

func New

func New() *Router

New returns a new initialized Router. Path auto-correction, including trailing slashes, is enabled by default.

func (*Router) Lookup

func (r *Router) Lookup(path string) (Handler, trie.Params)

Lookup allows the manual lookup of a path combo. This is e.g. useful to build a framework around this router. If the path was found, it returns the handle function and the path parameter values.

func (*Router) Register

func (r *Router) Register(path string, handle Handler)

Register registers a new request handle with the given path. This function is intended for bulk loading and to allow the usage of less frequently used, non-standardized or custom methods (e.g. for internal communication with a proxy).

Jump to

Keyboard shortcuts

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