tree

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HandlerExistsError      = "A handler for the path already exists"
	HandlerDoesntExistError = "A handler for that path does not exist"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PathTree

type PathTree struct {
	Root *RouteNode
}

func NewPathTree

func NewPathTree() *PathTree

func (*PathTree) Insert

func (t *PathTree) Insert(method string, path string, fn common.HandlerFunc) error

func (*PathTree) Search

func (t *PathTree) Search(path string) (*RouteNode, error)

type RouteNode

type RouteNode struct {
	PathSegment     string
	Children        map[string]*RouteNode
	RequestHandlers map[string]common.HandlerFunc
}

func NewRouteNode

func NewRouteNode(path string) *RouteNode

func (*RouteNode) AddHandler

func (n *RouteNode) AddHandler(method string, fn common.HandlerFunc) error

func (*RouteNode) GetHandler

func (n *RouteNode) GetHandler(method string) (common.HandlerFunc, error)

Jump to

Keyboard shortcuts

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