admin filter finish to all router include static file
so if your web is need auth or release the resoure you can writer the finish filter
Showing
1 changed file
with
12 additions
and
0 deletions
| ... | @@ -844,6 +844,18 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -844,6 +844,18 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 844 | } | 844 | } |
| 845 | 845 | ||
| 846 | Admin: | 846 | Admin: |
| 847 | if p.enableFilter { | ||
| 848 | if l, ok := p.filters["Finish"]; ok { | ||
| 849 | for _, filterR := range l { | ||
| 850 | if filterR.ValidRouter(r.URL.Path) { | ||
| 851 | filterR.filterFunc(context) | ||
| 852 | if w.started { | ||
| 853 | break | ||
| 854 | } | ||
| 855 | } | ||
| 856 | } | ||
| 857 | } | ||
| 858 | } | ||
| 847 | //admin module record QPS | 859 | //admin module record QPS |
| 848 | if EnableAdmin { | 860 | if EnableAdmin { |
| 849 | timeend := time.Since(starttime) | 861 | timeend := time.Since(starttime) | ... | ... |
-
Please register or sign in to post a comment