Skip to content

Commit 1e749b8

Browse files
authored
Add route handler info for debugging purpose (#30705)
Follow #30519
1 parent 68a3e6b commit 1e749b8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

routers/init.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package routers
55

66
import (
77
"context"
8+
"net/http"
89
"reflect"
910
"runtime"
1011

@@ -25,6 +26,7 @@ import (
2526
"code.gitea.io/gitea/modules/templates"
2627
"code.gitea.io/gitea/modules/translation"
2728
"code.gitea.io/gitea/modules/web"
29+
"code.gitea.io/gitea/modules/web/routing"
2830
actions_router "code.gitea.io/gitea/routers/api/actions"
2931
packages_router "code.gitea.io/gitea/routers/api/packages"
3032
apiv1 "code.gitea.io/gitea/routers/api/v1"
@@ -202,5 +204,9 @@ func NormalRoutes() *web.Route {
202204
r.Mount(prefix, actions_router.ArtifactsV4Routes(prefix))
203205
}
204206

207+
r.NotFound(func(w http.ResponseWriter, req *http.Request) {
208+
routing.UpdateFuncInfo(req.Context(), routing.GetFuncInfo(http.NotFound, "GlobalNotFound"))
209+
http.NotFound(w, req)
210+
})
205211
return r
206212
}

routers/web/web.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ func registerRoutes(m *web.Route) {
16121612

16131613
m.NotFound(func(w http.ResponseWriter, req *http.Request) {
16141614
ctx := context.GetWebContext(req)
1615-
routing.UpdateFuncInfo(ctx, routing.GetFuncInfo(ctx.NotFound, "GlobalNotFound"))
1615+
routing.UpdateFuncInfo(ctx, routing.GetFuncInfo(ctx.NotFound, "WebNotFound"))
16161616
ctx.NotFound("", nil)
16171617
})
16181618
}

0 commit comments

Comments
 (0)