From f58f5bb3d8a92f30112d8914ed7006b72e28df05 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 12 Feb 2025 14:25:46 +0800 Subject: Avoid duplicate SetContextValue call (#33564) And fix FIXME and TODO --- services/context/context.go | 1 - services/context/package.go | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'services/context') 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) }) } -- cgit v1.2.3