radix

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Route added in v0.9.2

func Route[T context, H any](n *Node[H], path string, ctx T) (handle H, ok, tsr bool)

Route returns the handle registered with the given path (key). The values of wildcard values are set on the context via UnderlyingSetPathParam.

If no handle can be found, a TSR (trailing slash redirect) recommendation is made if a handle exists with an extra (without the) trailing slash for the given path.

Types

type Node

type Node[H any] struct {
	// contains filtered or unexported fields
}

Node is a node in the radix tree.

func (*Node[H]) AddRoute

func (n *Node[H]) AddRoute(path string, handle H)

AddRoute adds a node with the given handle to the path. Not concurrency-safe!

func (*Node[H]) FindCaseInsensitivePath

func (n *Node[H]) FindCaseInsensitivePath(path string, fixTrailingSlash bool) (fixedPath string, found bool)

FindCaseInsensitivePath makes a case-insensitive lookup of the given path to find a route with a registered handle.

It can optionally also fix trailing slashes.

It returns the case-corrected path and a bool indicating whether the lookup was successful.

func (*Node[H]) Route added in v0.9.3

func (n *Node[H]) Route(path string) (handle H, ok, tsr bool)

Route returns the handle registered with the given path (key).

If no handle can be found, a TSR (trailing slash redirect) recommendation is made if a handle exists with an extra (without the) trailing slash for the given path.

Jump to

Keyboard shortcuts

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