1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-10 20:40:55 +00:00
Beego/filter.go

30 lines
965 B
Go
Raw Normal View History

2014-04-12 05:18:18 +00:00
// Beego (http://beego.me/)
// @description beego is an open-source, high-performance web framework for the Go programming language.
// @link http://github.com/astaxie/beego for the canonical source repository
// @license http://github.com/astaxie/beego/blob/master/LICENSE
// @authors astaxie
2013-09-09 16:00:11 +00:00
package beego
// 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
}
// 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
}