radix

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 fasthttp.RequestHandler)

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, ctx *fasthttp.RequestCtx) (fasthttp.RequestHandler, 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