Documentation
¶
Index ¶
Constants ¶
const ( ParamCharacter = ':' WildcardCharacter = '*' )
Variables ¶
This section is empty.
Functions ¶
func NextSeparator ¶
NextSeparator returns an index of next separator in path.
func ParamNames ¶
ParamNames returns parameter names in given path. It returns names which meta character is prefixed.
Types ¶
type Record ¶
type Record struct {
// Key for a router construction.
Key string
// Result value for Key.
Value interface{}
}
Record represents a record data for a router construction.
type Router ¶
type Router interface {
// New returns a new URLRouter.
New() URLRouter
}
Router is an interface of factory of URLRouter.
type URLRouter ¶
type URLRouter interface {
// Lookup returns data and path parameters that associated with path.
// params is a slice of the Param that arranged in the order in which parameters appeared.
// e.g. when built routing path is "/path/:id/:name" and given path is "/path/to/1/alice". params order is [{"id": "1"}, {"name": "alice"}], not [{"name": "alice"}, {"id": "1"}].
// If failed to lookup, data will be nil.
Lookup(path string) (data interface{}, params []Param)
// Build builds URL router from records.
Build(records []Record) error
}
URLRouter is an interface that must be implemented by a URL router.
func NewURLRouter ¶
NewURLRouter returns the URLRouter with the specified name.
Directories
¶
| Path | Synopsis |
|---|---|
|
A URL router implemented by Double-Array Trie.
|
A URL router implemented by Double-Array Trie. |
|
A URL router implemented by Regular-Expression.
|
A URL router implemented by Regular-Expression. |
|
A URL router implemented by Ternary Search Tree.
|
A URL router implemented by Ternary Search Tree. |
