2014-04-12 05:18:18 +00:00
|
|
|
// Beego (http://beego.me/)
|
2014-06-25 02:39:37 +00:00
|
|
|
|
2014-04-12 05:18:18 +00:00
|
|
|
// @description beego is an open-source, high-performance web framework for the Go programming language.
|
2014-06-25 02:39:37 +00:00
|
|
|
|
2014-04-12 05:18:18 +00:00
|
|
|
// @link http://github.com/astaxie/beego for the canonical source repository
|
2014-06-25 02:39:37 +00:00
|
|
|
|
2014-04-12 05:18:18 +00:00
|
|
|
// @license http://github.com/astaxie/beego/blob/master/LICENSE
|
2014-06-25 02:39:37 +00:00
|
|
|
|
2014-04-12 05:18:18 +00:00
|
|
|
// @authors astaxie
|
|
|
|
|
2013-09-09 16:00:11 +00:00
|
|
|
package beego
|
|
|
|
|
2013-12-20 13:16:26 +00:00
|
|
|
// FilterRouter defines filter operation before controller handler execution.
|
|
|
|
// it can match patterned url and do filter function when action arrives.
|
2013-09-09 16:00:11 +00:00
|
|
|
type FilterRouter struct {
|
2014-06-08 12:24:01 +00:00
|
|
|
filterFunc FilterFunc
|
|
|
|
tree *Tree
|
|
|
|
pattern string
|
2013-09-09 16:00:11 +00:00
|
|
|
}
|
|
|
|
|
2013-12-20 13:16:26 +00:00
|
|
|
// ValidRouter check current request is valid for this filter.
|
|
|
|
// if matched, returns parsed params in this request by defined filter router pattern.
|
2014-06-08 12:24:01 +00:00
|
|
|
func (f *FilterRouter) ValidRouter(router string) (bool, map[string]string) {
|
|
|
|
isok, params := f.tree.Match(router)
|
|
|
|
if isok == nil {
|
|
|
|
return false, nil
|
2013-09-09 16:00:11 +00:00
|
|
|
}
|
2014-06-08 12:24:01 +00:00
|
|
|
if isok, ok := isok.(bool); ok {
|
|
|
|
return isok, params
|
|
|
|
} else {
|
|
|
|
return false, nil
|
2013-09-09 16:00:11 +00:00
|
|
|
}
|
2013-11-26 08:47:50 +00:00
|
|
|
}
|