Skip to content

Commit 53ddc45

Browse files
committed
fix
1 parent 2e2d4be commit 53ddc45

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

routers/install/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func Contexter() func(next http.Handler) http.Handler {
6464
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
6565
base := context.NewBaseContext(resp, req)
6666
ctx := context.NewWebContext(base, rnd, session.GetSession(req))
67-
ctx.SetContextValue(context.WebContextKey, ctx)
67+
ctx.SetContextValue(context.WebContextKey, ctx) // FIXME: this should be removed because NewWebContext should already set it
6868
ctx.Data.MergeFrom(middleware.CommonTemplateContextData())
6969
ctx.Data.MergeFrom(reqctx.ContextData{
7070
"Title": ctx.Locale.Tr("install.install"),

routers/private/internal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func Routes() *web.Router {
8888
// Fortunately, the LFS handlers are able to handle requests without a complete web context
8989
common.AddOwnerRepoGitLFSRoutes(r, func(ctx *context.PrivateContext) {
9090
webContext := &context.Context{Base: ctx.Base}
91-
ctx.SetContextValue(context.WebContextKey, webContext)
91+
ctx.SetContextValue(context.WebContextKey, webContext) // FIXME: this is not ideal but no other way at the moment
9292
})
9393
})
9494

services/context/context.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ func NewWebContext(base *Base, render Render, session session.Store) *Context {
135135
}
136136
ctx.TemplateContext = NewTemplateContextForWeb(ctx)
137137
ctx.Flash = &middleware.Flash{DataStore: ctx, Values: url.Values{}}
138+
ctx.SetContextValue(WebContextKey, ctx)
138139
return ctx
139140
}
140141

@@ -165,7 +166,7 @@ func Contexter() func(next http.Handler) http.Handler {
165166
ctx.PageData = map[string]any{}
166167
ctx.Data["PageData"] = ctx.PageData
167168

168-
ctx.Base.SetContextValue(WebContextKey, ctx)
169+
ctx.Base.SetContextValue(WebContextKey, ctx) // FIXME: this should be removed because NewWebContext should already set it
169170
ctx.Csrf = NewCSRFProtector(csrfOpts)
170171

171172
// get the last flash message from cookie

services/context/package.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func PackageContexter() func(next http.Handler) http.Handler {
156156
base := NewBaseContext(resp, req)
157157
// it is still needed when rendering 500 page in a package handler
158158
ctx := NewWebContext(base, renderer, nil)
159-
ctx.SetContextValue(WebContextKey, ctx)
159+
ctx.SetContextValue(WebContextKey, ctx) // FIXME: this should be removed because NewWebContext should already set it
160160
next.ServeHTTP(ctx.Resp, ctx.Req)
161161
})
162162
}

services/contexttest/context_tests.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func MockContext(t *testing.T, reqPath string, opts ...MockContextOption) (*cont
6767

6868
chiCtx := chi.NewRouteContext()
6969
ctx := context.NewWebContext(base, opt.Render, nil)
70-
ctx.SetContextValue(context.WebContextKey, ctx)
70+
ctx.SetContextValue(context.WebContextKey, ctx) // FIXME: this should be removed because NewWebContext should already set it
7171
ctx.SetContextValue(chi.RouteCtxKey, chiCtx)
7272
if opt.SessionStore != nil {
7373
ctx.SetContextValue(session.MockStoreContextKey, opt.SessionStore)

0 commit comments

Comments
 (0)