mux

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package mux provide route tree

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

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

Node is route node

func NewNode

func NewNode(root *Node, id string) *Node

NewNode creates new tre node

func NewRoot

func NewRoot(id string) *Node

NewRoot create new tree root

func (*Node) AddChild

func (n *Node) AddChild(ids []string) *Node

AddChild adds child by ids

func (*Node) Children

func (n *Node) Children() *Tree

Children returns node's children as tree

func (*Node) GetChild

func (n *Node) GetChild(ids []string) (*Node, context.Params)

GetChild gets child by ids

func (*Node) GetChildByPath

func (n *Node) GetChildByPath(path string) (*Node, context.Params, string)

GetChildByPath accepts string path then returns: child node as a first arg, parameters built from wildcards, and part of path (this is used to strip request path for sub routers)

func (*Node) ID

func (n *Node) ID() string

ID returns node's id

func (*Node) IsLeaf

func (n *Node) IsLeaf() bool

IsLeaf returns true if node is root

func (*Node) IsRoot

func (n *Node) IsRoot() bool

IsRoot returns true if node is root

func (*Node) IsSubrouter

func (n *Node) IsSubrouter() bool

IsSubrouter returns true if node is subrouter

func (*Node) Route

func (n *Node) Route() Route

Route returns node's route

func (*Node) SetRegexp

func (n *Node) SetRegexp(exp string)

SetRegexp sets node regexp value

func (*Node) SetRoute

func (n *Node) SetRoute(r Route)

SetRoute sets node route value

func (*Node) TurnIntoSubrouter

func (n *Node) TurnIntoSubrouter()

TurnIntoSubrouter sets node as subrouter

type Route

type Route interface {
	Handler() interface{}
	AppendMiddleware(m middleware.Middleware)
	PrependMiddleware(m middleware.Middleware)
}

Route is an middleware aware route interface

type Tree

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

Tree of routes

func NewTree

func NewTree() *Tree

NewTree provides new node tree

func (*Tree) GetByID

func (t *Tree) GetByID(id string) *Node

GetByID gets node by ID

func (*Tree) GetByPath

func (t *Tree) GetByPath(path string) (*Node, string, string)

GetByPath gets node by path

func (*Tree) Insert

func (t *Tree) Insert(n *Node)

Insert inserts node

func (*Tree) RegexpNodes

func (t *Tree) RegexpNodes() []*Node

RegexpNodes returns tree regexp nodes

func (*Tree) StaticNodes

func (t *Tree) StaticNodes() map[int]*Node

StaticNodes returns tree static nodes

func (*Tree) WildcardNode

func (t *Tree) WildcardNode() *Node

WildcardNode returns tree wildcard node

Jump to

Keyboard shortcuts

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