diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2025-02-12 14:25:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-12 14:25:46 +0800 |
commit | f58f5bb3d8a92f30112d8914ed7006b72e28df05 (patch) | |
tree | d98327e00983123d28dc1298e9c1a8ec3e192a0a /services/context | |
parent | 06f10656369c7e4274ae4e9f9edb21e1cac520d9 (diff) | |
download | gitea-f58f5bb3d8a92f30112d8914ed7006b72e28df05.tar.gz gitea-f58f5bb3d8a92f30112d8914ed7006b72e28df05.zip |
Avoid duplicate SetContextValue call (#33564)
And fix FIXME and TODO
Diffstat (limited to 'services/context')
-rw-r--r-- | services/context/context.go | 1 | ||||
-rw-r--r-- | services/context/package.go | 4 |
2 files changed, 2 insertions, 3 deletions
diff --git a/services/context/context.go b/services/context/context.go index ffce1d617a..5e08fba442 100644 --- a/services/context/context.go +++ b/services/context/context.go @@ -166,7 +166,6 @@ func Contexter() func(next http.Handler) http.Handler { ctx.PageData = map[string]any{} ctx.Data["PageData"] = ctx.PageData - ctx.Base.SetContextValue(WebContextKey, ctx) // FIXME: this should be removed because NewWebContext should already set it ctx.Csrf = NewCSRFProtector(csrfOpts) // get the last flash message from cookie diff --git a/services/context/package.go b/services/context/package.go index e566b7e532..e32ba3b481 100644 --- a/services/context/package.go +++ b/services/context/package.go @@ -154,9 +154,9 @@ func PackageContexter() func(next http.Handler) http.Handler { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { base := NewBaseContext(resp, req) - // it is still needed when rendering 500 page in a package handler + // FIXME: web Context is still needed when rendering 500 page in a package handler + // It should be refactored to use new error handling mechanisms ctx := NewWebContext(base, renderer, nil) - ctx.SetContextValue(WebContextKey, ctx) // FIXME: this should be removed because NewWebContext should already set it next.ServeHTTP(ctx.Resp, ctx.Req) }) } |