mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:50:55 +00:00
file the static filter
This commit is contained in:
parent
10db97b193
commit
8d797a4a5e
28
router.go
28
router.go
@ -72,11 +72,31 @@ var (
|
|||||||
"SetSecureCookie", "XsrfToken", "CheckXsrfCookie", "XsrfFormHtml",
|
"SetSecureCookie", "XsrfToken", "CheckXsrfCookie", "XsrfFormHtml",
|
||||||
"GetControllerAndAction"}
|
"GetControllerAndAction"}
|
||||||
|
|
||||||
url_placeholder = "{{placeholder}}"
|
url_placeholder = "{{placeholder}}"
|
||||||
|
DefaultLogFilter FilterHandler = &logFilter{}
|
||||||
FilterRouterLog func(*beecontext.Context) bool
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type FilterHandler interface {
|
||||||
|
Filter(*beecontext.Context) bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// default log filter static file will not show
|
||||||
|
type logFilter struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *logFilter) Filter(ctx *beecontext.Context) bool {
|
||||||
|
requestPath := path.Clean(ctx.Input.Request.URL.Path)
|
||||||
|
if requestPath == "/favicon.ico" || requestPath == "/robots.txt" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
for prefix, _ := range StaticDir {
|
||||||
|
if strings.HasPrefix(requestPath, prefix) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// To append a slice's value into "exceptMethod", for controller's methods shouldn't reflect to AutoRouter
|
// To append a slice's value into "exceptMethod", for controller's methods shouldn't reflect to AutoRouter
|
||||||
func ExceptMethodAppend(action string) {
|
func ExceptMethodAppend(action string) {
|
||||||
exceptMethod = append(exceptMethod, action)
|
exceptMethod = append(exceptMethod, action)
|
||||||
@ -815,7 +835,7 @@ Admin:
|
|||||||
} else {
|
} else {
|
||||||
devinfo = fmt.Sprintf("| % -10s | % -40s | % -16s | % -10s |", r.Method, r.URL.Path, timeend.String(), "notmatch")
|
devinfo = fmt.Sprintf("| % -10s | % -40s | % -16s | % -10s |", r.Method, r.URL.Path, timeend.String(), "notmatch")
|
||||||
}
|
}
|
||||||
if FilterRouterLog == nil || !FilterRouterLog(context) {
|
if DefaultLogFilter == nil || !DefaultLogFilter.Filter(context) {
|
||||||
Debug(devinfo)
|
Debug(devinfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user