Improve documentation of filter.go.
Showing
1 changed file
with
9 additions
and
7 deletions
| ... | @@ -16,11 +16,12 @@ package beego | ... | @@ -16,11 +16,12 @@ package beego |
| 16 | 16 | ||
| 17 | import "github.com/astaxie/beego/context" | 17 | import "github.com/astaxie/beego/context" |
| 18 | 18 | ||
| 19 | // FilterFunc defines filter function type. | 19 | // FilterFunc defines a filter function which is invoked before the controller handler is executed. |
| 20 | type FilterFunc func(*context.Context) | 20 | type FilterFunc func(*context.Context) |
| 21 | 21 | ||
| 22 | // FilterRouter defines filter operation before controller handler execution. | 22 | // FilterRouter defines a filter operation which is invoked before the controller handler is executed. |
| 23 | // it can match patterned url and do filter function when action arrives. | 23 | // It can match the URL against a pattern, and execute a filter function |
| 24 | // when a request with a matching URL arrives. | ||
| 24 | type FilterRouter struct { | 25 | type FilterRouter struct { |
| 25 | filterFunc FilterFunc | 26 | filterFunc FilterFunc |
| 26 | tree *Tree | 27 | tree *Tree |
| ... | @@ -28,10 +29,11 @@ type FilterRouter struct { | ... | @@ -28,10 +29,11 @@ type FilterRouter struct { |
| 28 | returnOnOutput bool | 29 | returnOnOutput bool |
| 29 | } | 30 | } |
| 30 | 31 | ||
| 31 | // ValidRouter check current request is valid for this filter. | 32 | // ValidRouter checks if the current request is matched by this filter. |
| 32 | // if matched, returns parsed params in this request by defined filter router pattern. | 33 | // If the request is matched, the values of the URL parameters defined |
| 33 | func (f *FilterRouter) ValidRouter(router string) (bool, map[string]string) { | 34 | // by the filter pattern are also returned. |
| 34 | isok, params := f.tree.Match(router) | 35 | func (f *FilterRouter) ValidRouter(url string) (bool, map[string]string) { |
| 36 | isok, params := f.tree.Match(url) | ||
| 35 | if isok == nil { | 37 | if isok == nil { |
| 36 | return false, nil | 38 | return false, nil |
| 37 | } | 39 | } | ... | ... |
-
Please register or sign in to post a comment