]> source.dussan.org Git - gitea.git/commitdiff
Add route handler info for debugging purpose (#30705)
authorwxiaoguang <wxiaoguang@gmail.com>
Fri, 26 Apr 2024 09:09:49 +0000 (17:09 +0800)
committerGitHub <noreply@github.com>
Fri, 26 Apr 2024 09:09:49 +0000 (09:09 +0000)
Follow #30519

routers/init.go
routers/web/web.go

index aaf95920c2e6f0549d715f4c9cd33374264b92d2..030ef3c740d8826d7e571123284446fc48e74fcd 100644 (file)
@@ -5,6 +5,7 @@ package routers
 
 import (
        "context"
+       "net/http"
        "reflect"
        "runtime"
 
@@ -25,6 +26,7 @@ import (
        "code.gitea.io/gitea/modules/templates"
        "code.gitea.io/gitea/modules/translation"
        "code.gitea.io/gitea/modules/web"
+       "code.gitea.io/gitea/modules/web/routing"
        actions_router "code.gitea.io/gitea/routers/api/actions"
        packages_router "code.gitea.io/gitea/routers/api/packages"
        apiv1 "code.gitea.io/gitea/routers/api/v1"
@@ -202,5 +204,9 @@ func NormalRoutes() *web.Route {
                r.Mount(prefix, actions_router.ArtifactsV4Routes(prefix))
        }
 
+       r.NotFound(func(w http.ResponseWriter, req *http.Request) {
+               routing.UpdateFuncInfo(req.Context(), routing.GetFuncInfo(http.NotFound, "GlobalNotFound"))
+               http.NotFound(w, req)
+       })
        return r
 }
index c6132f0d61b954480526c58aa5adb2f29a766404..9a6687059b8f2d132de14a3ebc4549b029145544 100644 (file)
@@ -1612,7 +1612,7 @@ func registerRoutes(m *web.Route) {
 
        m.NotFound(func(w http.ResponseWriter, req *http.Request) {
                ctx := context.GetWebContext(req)
-               routing.UpdateFuncInfo(ctx, routing.GetFuncInfo(ctx.NotFound, "GlobalNotFound"))
+               routing.UpdateFuncInfo(ctx, routing.GetFuncInfo(ctx.NotFound, "WebNotFound"))
                ctx.NotFound("", nil)
        })
 }