1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-04 09:20:18 +00:00

Add annotated filter, support @Import, @Filter.

Signed-off-by: Colstuwjx <Colstuwjx@gmail.com>
This commit is contained in:
Colstuwjx
2018-09-07 12:14:13 +08:00
parent 053a075344
commit 1cbba4d56f
3 changed files with 225 additions and 13 deletions

View File

@ -43,7 +43,7 @@ const (
)
const (
routerTypeBeego = iota
routerTypeBeego = iota
routerTypeRESTFul
routerTypeHandler
)
@ -277,6 +277,10 @@ func (p *ControllerRegister) Include(cList ...ControllerInterface) {
key := t.PkgPath() + ":" + t.Name()
if comm, ok := GlobalControllerRouter[key]; ok {
for _, a := range comm {
for _, f := range a.Filters {
p.InsertFilter(f.Pattern, f.Pos, f.Filter, f.ReturnOnOutput, f.ResetParams)
}
p.addWithMethodParams(a.Router, c, a.MethodParams, strings.Join(a.AllowHTTPMethods, ",")+":"+a.Method)
}
}
@ -877,7 +881,7 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
}
Admin:
//admin module record QPS
//admin module record QPS
statusCode := context.ResponseWriter.Status
if statusCode == 0 {