mirror of
https://github.com/astaxie/beego.git
synced 2024-11-05 02:30:55 +00:00
Merge pull request #1140 from cr7pt0gr4ph7/doc-pull-request
Improve documentation of filter.go.
This commit is contained in:
commit
b4880c5e1d
16
filter.go
16
filter.go
@ -16,11 +16,12 @@ package beego
|
|||||||
|
|
||||||
import "github.com/astaxie/beego/context"
|
import "github.com/astaxie/beego/context"
|
||||||
|
|
||||||
// FilterFunc defines filter function type.
|
// FilterFunc defines a filter function which is invoked before the controller handler is executed.
|
||||||
type FilterFunc func(*context.Context)
|
type FilterFunc func(*context.Context)
|
||||||
|
|
||||||
// FilterRouter defines filter operation before controller handler execution.
|
// FilterRouter defines a filter operation which is invoked before the controller handler is executed.
|
||||||
// it can match patterned url and do filter function when action arrives.
|
// It can match the URL against a pattern, and execute a filter function
|
||||||
|
// when a request with a matching URL arrives.
|
||||||
type FilterRouter struct {
|
type FilterRouter struct {
|
||||||
filterFunc FilterFunc
|
filterFunc FilterFunc
|
||||||
tree *Tree
|
tree *Tree
|
||||||
@ -28,10 +29,11 @@ type FilterRouter struct {
|
|||||||
returnOnOutput bool
|
returnOnOutput bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidRouter check current request is valid for this filter.
|
// ValidRouter checks if the current request is matched by this filter.
|
||||||
// if matched, returns parsed params in this request by defined filter router pattern.
|
// If the request is matched, the values of the URL parameters defined
|
||||||
func (f *FilterRouter) ValidRouter(router string) (bool, map[string]string) {
|
// by the filter pattern are also returned.
|
||||||
isok, params := f.tree.Match(router)
|
func (f *FilterRouter) ValidRouter(url string) (bool, map[string]string) {
|
||||||
|
isok, params := f.tree.Match(url)
|
||||||
if isok == nil {
|
if isok == nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user