router

package
v0.0.0-...-c18a219 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
}

Options represents route tree options.

type Route

type Route interface {
	//Method() string
	Path() string
	Handler() interface{}
	Params() []string
	URL(params ...interface{}) string
}

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

Tree represents a route tree based on Trie data structure.

func New

func New(opts Options) *Tree

New creates a route tree.

func (*Tree) Add

func (t *Tree) Add(method, path string, handler interface{}) (Route, error)

Add register a route with specific methods to the tree.

func (*Tree) Find

func (t *Tree) Find(method, path string, paramValues []string) (r Route, tsr bool)

Find tries to find a matched route in the tree.

func (*Tree) MaxParam

func (t *Tree) MaxParam() int

MaxParam returns max parameters of all routes.

func (*Tree) Print

func (t *Tree) Print(w io.Writer)

Print prints all routes.

func (*Tree) Walk

func (t *Tree) Walk(fn func(r Route, method string))

Walk traverses all route nodes of tree.

Jump to

Keyboard shortcuts

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