1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-13 16:31:01 +00:00

reuse map in tree.Match

This commit is contained in:
astaxie
2015-12-11 13:51:01 +08:00
parent 80bc372f17
commit 2b651fbae2
4 changed files with 94 additions and 97 deletions

View File

@ -32,13 +32,13 @@ type FilterRouter struct {
// ValidRouter checks if the current request is matched by this filter.
// If the request is matched, the values of the URL parameters defined
// by the filter pattern are also returned.
func (f *FilterRouter) ValidRouter(url string) (bool, map[string]string) {
isok, params := f.tree.Match(url)
func (f *FilterRouter) ValidRouter(url string, ctx *context.Context) bool {
isok := f.tree.Match(url, ctx)
if isok == nil {
return false, nil
return false
}
if isok, ok := isok.(bool); ok {
return isok, params
return isok
}
return false, nil
return false
}