Documentation ¶
Index ¶
- type CallbackParams
- type PathParams
- type RouteMgr
- func (r *RouteMgr) Execute(path string) bool
- func (r *RouteMgr) Handle(pattern string, value interface{})
- func (r *RouteMgr) Process(path string) (interface{}, *PathParams)
- func (r *RouteMgr) RegisterRoute(url string, callback func(*CallbackParams), title string)
- func (r *RouteMgr) RegisterRouteWithPrev(url string, callback func(*CallbackParams), title string)
- func (r *RouteMgr) RegisterSimpleRoute(url string, callback func(), title string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallbackParams ¶
type CallbackParams struct { PathParams *PathParams Path string PreviousPath string }
CallbackParams is send to Callback in Execute PreviousPath is empty by default, you have to register callback use RegisterRouteWithPrev method
type PathParams ¶
type PathParams struct {
// contains filtered or unexported fields
}
PathParams contains value of the path params
func (*PathParams) Get ¶
func (pp *PathParams) Get(key string) string
Get returns value of the param path using its key
type RouteMgr ¶
type RouteMgr struct { Debug bool // contains filtered or unexported fields }
RouteMgr allows register patterns with values and get it back
func New ¶
func New() *RouteMgr
New creates new route manager If debug true then Process will print pattern
func (*RouteMgr) Execute ¶
Execute calls function of the handled path Handled value should be func(p *CallbackParams) returns true if the path was found and the handler was executed
func (*RouteMgr) Process ¶
func (r *RouteMgr) Process(path string) (interface{}, *PathParams)
Process finds path and returns saved value and path parameters from pattern
func (*RouteMgr) RegisterRoute ¶
func (r *RouteMgr) RegisterRoute(url string, callback func(*CallbackParams), title string)
RegisterRoute handles a callback that will be called in the Execute method. Before callback call the path will be set in the URL bar and your title will be set if it not empty
func (*RouteMgr) RegisterRouteWithPrev ¶
func (r *RouteMgr) RegisterRouteWithPrev(url string, callback func(*CallbackParams), title string)
RegisterRouteWithPrev adds previous path to CallbackParams
func (*RouteMgr) RegisterSimpleRoute ¶
RegisterSimpleRoute handles a callback without PathParams and path arguments Use it if you don't need them