diff --git a/contracts/http/context.go b/contracts/http/context.go index 7cb8def8a..aae068226 100644 --- a/contracts/http/context.go +++ b/contracts/http/context.go @@ -30,5 +30,5 @@ type Context interface { // Response returns the ContextResponse Response() ContextResponse // SetContext set the custom context - SetContext(ctx Context) + SetContext(ctx context.Context) } diff --git a/foundation/application.go b/foundation/application.go index 60e58b7d9..4f0479dba 100644 --- a/foundation/application.go +++ b/foundation/application.go @@ -112,7 +112,8 @@ func (app *Application) GetLocale(ctx context.Context) string { } func (app *Application) SetLocaleByHttp(ctx http.Context, locale string) { - app.MakeLang(ctx).SetLocale(locale) + ctxWithLocale := app.MakeLang(ctx).SetLocale(locale) + ctx.SetContext(ctxWithLocale) } func (app *Application) SetLocale(ctx context.Context, locale string) context.Context { diff --git a/http/context.go b/http/context.go index 3c3b42b27..297140c27 100644 --- a/http/context.go +++ b/http/context.go @@ -39,6 +39,6 @@ func (r *Context) Response() http.ContextResponse { return nil } -func (r *Context) SetContext(ctx http.Context) { - r.Ctx = ctx.Context() +func (r *Context) SetContext(ctx context.Context) { + r.Ctx = ctx } diff --git a/http/context_test.go b/http/context_test.go index d5712ba8a..9f6575bdd 100644 --- a/http/context_test.go +++ b/http/context_test.go @@ -38,7 +38,6 @@ func (s *ContextTestSuite) TestResponse() { } func (s *ContextTestSuite) TestSetContext() { - ctx := NewContext() - s.ctx.SetContext(ctx) - s.Equal(ctx.Context(), s.ctx.Context()) + s.ctx.SetContext(context.Background()) + s.Equal(context.Background(), s.ctx.Context()) } diff --git a/http/middleware/throttle_test.go b/http/middleware/throttle_test.go index 4ea82c255..857cc2449 100644 --- a/http/middleware/throttle_test.go +++ b/http/middleware/throttle_test.go @@ -283,7 +283,7 @@ func (r *TestContext) Response() contractshttp.ContextResponse { return r.response } -func (r *TestContext) SetContext(ctx contractshttp.Context) { +func (r *TestContext) SetContext(ctx context.Context) { panic("do not need to implement it") }