aboutsummaryrefslogtreecommitdiffstats
path: root/services/context
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2025-01-16 04:05:18 +0800
committerGitHub <noreply@github.com>2025-01-15 20:05:18 +0000
commitb15d01b0cec32f34fafc41eaa97887305b1376f7 (patch)
treedf61d3cd92ab3fe07fa9ba4278cd2f290d55c943 /services/context
parent6659a381ea19acfc18eb5660bd6223a1e19147e4 (diff)
downloadgitea-b15d01b0cec32f34fafc41eaa97887305b1376f7.tar.gz
gitea-b15d01b0cec32f34fafc41eaa97887305b1376f7.zip
Prepare for support performance trace (#33286)
For #32973
Diffstat (limited to 'services/context')
-rw-r--r--services/context/base.go24
1 files changed, 11 insertions, 13 deletions
diff --git a/services/context/base.go b/services/context/base.go
index 7a39353e09..5db84f42a5 100644
--- a/services/context/base.go
+++ b/services/context/base.go
@@ -4,7 +4,6 @@
package context
import (
- "context"
"fmt"
"html/template"
"io"
@@ -25,8 +24,7 @@ type BaseContextKeyType struct{}
var BaseContextKey BaseContextKeyType
type Base struct {
- context.Context
- reqctx.RequestDataStore
+ reqctx.RequestContext
Resp ResponseWriter
Req *http.Request
@@ -172,19 +170,19 @@ func (b *Base) TrN(cnt any, key1, keyN string, args ...any) template.HTML {
}
func NewBaseContext(resp http.ResponseWriter, req *http.Request) *Base {
- ds := reqctx.GetRequestDataStore(req.Context())
+ reqCtx := reqctx.FromContext(req.Context())
b := &Base{
- Context: req.Context(),
- RequestDataStore: ds,
- Req: req,
- Resp: WrapResponseWriter(resp),
- Locale: middleware.Locale(resp, req),
- Data: ds.GetData(),
+ RequestContext: reqCtx,
+
+ Req: req,
+ Resp: WrapResponseWriter(resp),
+ Locale: middleware.Locale(resp, req),
+ Data: reqCtx.GetData(),
}
b.Req = b.Req.WithContext(b)
- ds.SetContextValue(BaseContextKey, b)
- ds.SetContextValue(translation.ContextKey, b.Locale)
- ds.SetContextValue(httplib.RequestContextKey, b.Req)
+ reqCtx.SetContextValue(BaseContextKey, b)
+ reqCtx.SetContextValue(translation.ContextKey, b.Locale)
+ reqCtx.SetContextValue(httplib.RequestContextKey, b.Req)
return b
}