Skip to content

Commit

Permalink
Some following up changes for routes (#30550)
Browse files Browse the repository at this point in the history
1. Switch back to the old order for `reqRepoAdmin, context.RepoRef()`
2. Add a routing function info for global NotFound
  • Loading branch information
wxiaoguang authored Apr 18, 2024
1 parent d4ec6b3 commit d1ba5f4
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
)

const (
// GzipMinSize represents min size to compress for the body size of response
GzipMinSize = 1400
)
const GzipMinSize = 1400 // min size to compress for the body size of response

// optionsCorsHandler return a http handler which sets CORS options if enabled by config, it blocks non-CORS OPTIONS requests.
func optionsCorsHandler() func(next http.Handler) http.Handler {
Expand Down Expand Up @@ -1115,7 +1112,7 @@ func registerRoutes(m *web.Route) {
m.Post("/cancel", repo.MigrateCancelPost)
})
},
reqSignIn, context.RepoAssignment, context.RepoRef(), reqRepoAdmin,
reqSignIn, context.RepoAssignment, reqRepoAdmin, context.RepoRef(),
ctxDataSet("PageIsRepoSettings", true, "LFSStartServer", setting.LFS.StartServer),
)
// end "/{username}/{reponame}/settings"
Expand Down Expand Up @@ -1613,6 +1610,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"))
ctx.NotFound("", nil)
})
}

0 comments on commit d1ba5f4

Please sign in to comment.