Skip to content

Commit

Permalink
feat: [#243] Optimize the return of controller
Browse files Browse the repository at this point in the history
  • Loading branch information
hwbrzzl committed Sep 3, 2023
1 parent 8c9c2ea commit 4dd5ee8
Show file tree
Hide file tree
Showing 12 changed files with 410 additions and 256 deletions.
8 changes: 4 additions & 4 deletions auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type User struct {

type Context struct {
ctx context.Context
request http.Request
response http.Response
request http.ContextRequest
response http.ContextResponse
values map[string]any
mu sync.RWMutex
}
Expand Down Expand Up @@ -72,11 +72,11 @@ func (mc *Context) WithValue(key string, value any) {
mc.mu.Unlock()
}

func (mc *Context) Request() http.Request {
func (mc *Context) Request() http.ContextRequest {
return mc.request
}

func (mc *Context) Response() http.Response {
func (mc *Context) Response() http.ContextResponse {
return mc.response
}

Expand Down
16 changes: 8 additions & 8 deletions contracts/http/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import (
)

type Middleware func(Context)
type HandlerFunc func(Context)
type HandlerFunc func(Context) Response
type ResourceController interface {
Index(Context)
Show(Context)
Store(Context)
Update(Context)
Destroy(Context)
Index(Context) Response
Show(Context) Response
Store(Context) Response
Update(Context) Response
Destroy(Context) Response
}

//go:generate mockery --name=Context
type Context interface {
context.Context
Context() context.Context
WithValue(key string, value any)
Request() Request
Response() Response
Request() ContextRequest
Response() ContextResponse
}
16 changes: 8 additions & 8 deletions contracts/http/mocks/Context.go

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

Loading

0 comments on commit 4dd5ee8

Please sign in to comment.