radix

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRequestValue

func AddRequestValue(r *http.Request, key, val string) *http.Request

func UserValues

func UserValues(r *http.Request) map[string]string

func VisitUserValues

func VisitUserValues(r *http.Request, f func(key string, value string))

Types

type Tree

type Tree struct {

	// If enabled, the node handler could be updated
	Mutable bool
	// contains filtered or unexported fields
}

Tree is a routes storage

func New

func New() *Tree

New returns an empty routes storage

func (*Tree) Add

func (t *Tree) Add(path string, handler http.HandlerFunc)

Add adds a node with the given handle to the path.

WARNING: Not concurrency-safe!

func (*Tree) FindCaseInsensitivePath

func (t *Tree) FindCaseInsensitivePath(path string, fixTrailingSlash bool, buf *bytebufferpool.ByteBuffer) bool

FindCaseInsensitivePath makes a case-insensitive lookup of the given path and tries to find a handler. It can optionally also fix trailing slashes. It returns the case-corrected path and a bool indicating whether the lookup was successful.

func (*Tree) Get

func (t *Tree) Get(path string, r *http.Request) (http.HandlerFunc, bool)

Get returns the handle registered with the given path (key). The values of param/wildcard are saved as ctx.UserValue. 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