Skip to content

Commit

Permalink
Merge branch 'master' into kkumar-gcc/localization
Browse files Browse the repository at this point in the history
  • Loading branch information
kkumar-gcc committed Nov 17, 2023
2 parents 588179d + 50ecec9 commit ad9ea11
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func (mc *Context) Response() http.ContextResponse {
return mc.response
}

func (mc *Context) SetContext(ctx http.Context) {
mc.ctx = ctx.Context()
}

func Background() http.Context {
return &Context{
ctx: context.Background(),
Expand Down
2 changes: 2 additions & 0 deletions contracts/http/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ type Context interface {
Request() ContextRequest
// Response returns the ContextResponse
Response() ContextResponse
// SetContext set the custom context
SetContext(ctx Context)
}
4 changes: 4 additions & 0 deletions http/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ func (r *Context) Request() http.ContextRequest {
func (r *Context) Response() http.ContextResponse {
return nil
}

func (r *Context) SetContext(ctx http.Context) {
r.Ctx = ctx.Context()
}
6 changes: 6 additions & 0 deletions http/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ func (s *ContextTestSuite) TestRequest() {
func (s *ContextTestSuite) TestResponse() {
s.Nil(s.ctx.Response())
}

func (s *ContextTestSuite) TestSetContext() {
ctx := NewContext()
s.ctx.SetContext(ctx)
s.Equal(ctx.Context(), s.ctx.Context())
}
4 changes: 4 additions & 0 deletions http/middleware/throttle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ func (r *TestContext) Response() contractshttp.ContextResponse {
return r.response
}

func (r *TestContext) SetContext(ctx contractshttp.Context) {
panic("do not need to implement it")
}

type TestRequest struct{}

func (r *TestRequest) Header(key string, defaultValue ...string) string {
Expand Down
5 changes: 5 additions & 0 deletions mocks/http/Context.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ad9ea11

Please sign in to comment.