From c0bb5b9237dfd3292dd4e80c4c5c3f99dd1a9b86 Mon Sep 17 00:00:00 2001 From: cr7pt0gr4ph7 Date: Sun, 3 May 2015 23:21:32 +0200 Subject: [PATCH] Improve documentation of filter.go. --- filter.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/filter.go b/filter.go index ddd61094..f673ab66 100644 --- a/filter.go +++ b/filter.go @@ -16,11 +16,12 @@ package beego 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) -// FilterRouter defines filter operation before controller handler execution. -// it can match patterned url and do filter function when action arrives. +// FilterRouter defines a filter operation which is invoked before the controller handler is executed. +// It can match the URL against a pattern, and execute a filter function +// when a request with a matching URL arrives. type FilterRouter struct { filterFunc FilterFunc tree *Tree @@ -28,10 +29,11 @@ type FilterRouter struct { returnOnOutput bool } -// ValidRouter check current request is valid for this filter. -// if matched, returns parsed params in this request by defined filter router pattern. -func (f *FilterRouter) ValidRouter(router string) (bool, map[string]string) { - isok, params := f.tree.Match(router) +// 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) if isok == nil { return false, nil }