aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/web.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-01-20 19:41:25 +0800
committerGitHub <noreply@github.com>2022-01-20 19:41:25 +0800
commit5bf8d5445e3e3ec6b2be156654dcb233d78a570e (patch)
tree9a426fd03b619947b88931465c1a645540b94bfb /routers/web/web.go
parentbbd30787d3d33fe66896c7e758e6922be459e252 (diff)
downloadgitea-5bf8d5445e3e3ec6b2be156654dcb233d78a570e.tar.gz
gitea-5bf8d5445e3e3ec6b2be156654dcb233d78a570e.zip
Refactor Router Logger (#17308)
Make router logger more friendly, show the related function name/file/line. [BREAKING] This PR substantially changes the logging format of the router logger. If you use this logging for monitoring e.g. fail2ban you will need to update this to match the new format.
Diffstat (limited to 'routers/web/web.go')
-rw-r--r--routers/web/web.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/routers/web/web.go b/routers/web/web.go
index 55a64ee7d5..e934095b79 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -21,6 +21,7 @@ import (
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/validation"
"code.gitea.io/gitea/modules/web"
+ "code.gitea.io/gitea/modules/web/routing"
"code.gitea.io/gitea/routers/api/v1/misc"
"code.gitea.io/gitea/routers/web/admin"
"code.gitea.io/gitea/routers/web/auth"
@@ -73,11 +74,11 @@ func CorsHandler() func(next http.Handler) http.Handler {
func Routes(sessioner func(http.Handler) http.Handler) *web.Route {
routes := web.NewRoute()
- routes.Use(public.AssetsHandler(&public.Options{
+ routes.Use(web.WrapWithPrefix(public.AssetsURLPathPrefix, public.AssetsHandlerFunc(&public.Options{
Directory: path.Join(setting.StaticRootPath, "public"),
- Prefix: "/assets",
+ Prefix: public.AssetsURLPathPrefix,
CorsHandler: CorsHandler(),
- }))
+ }), "AssetsHandler"))
routes.Use(sessioner)
@@ -293,7 +294,7 @@ func RegisterRoutes(m *web.Route) {
})
}, reqSignOut)
- m.Any("/user/events", events.Events)
+ m.Any("/user/events", routing.MarkLongPolling, events.Events)
m.Group("/login/oauth", func() {
m.Get("/authorize", bindIgnErr(forms.AuthorizationForm{}), auth.AuthorizeOAuth)