router

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 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")
)

Functions

func IsValidHTTPMethod

func IsValidHTTPMethod(method string) bool

Types

type Children

type Children struct {
	Node *node
	Path string
}

type NodeType

type NodeType int32
const (
	Exact NodeType = iota
	PreferentialPrefix
	Prefix
	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