router

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists = errors.New("already exists")

ErrAlreadyExists is returned when a route already exists.

HTTPMethods is a list of supported HTTP methods.

Functions

func IsValidHTTPMethod

func IsValidHTTPMethod(method string) bool

IsValidHTTPMethod checks if the given method is a valid HTTP method.

Types

type Children

type Children struct {
	Node *node
	Path string
}

Children represents a child node with its path.

type NodeType

type NodeType int32

NodeType indicates the type of the node.

const (
	// Exact means the path must be matched exactly.
	Exact NodeType = iota
	// PreferentialPrefix means the path must be matched as a preferential prefix.
	PreferentialPrefix
	// Prefix means the path must be matched as a prefix.
	Prefix
	// Regex means the path must be matched as a regular expression.
	Regex
)

type Router

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

Router struct contains the Trie and handler chain.

func NewRouter

func NewRouter() *Router

NewRouter creates and returns a new router.

func (*Router) Add

func (r *Router) Add(method, path string, nodeType NodeType, middleware ...app.HandlerFunc) error

Add adds a route to radix tree.

func (*Router) Find

func (r *Router) Find(method string, path string) ([]app.HandlerFunc, bool)

Find searches the Trie for handler functions matching the route, returns the handler functions and whether the handler is deferred (genernal match).

Jump to

Keyboard shortcuts

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