Skip to content

Commit

Permalink
fix: paramter for invoker
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxu19830126 committed Dec 20, 2017
1 parent fd02f68 commit a01ab85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion http.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (s *httpServer) handleHTTP(c echo.Context, ep *httpEntrypoint) error {
}
}

rsp, err := ep.invoker(req)
rsp, err := ep.invoker(req, c)
if err != nil {
return c.String(http.StatusInternalServerError, err.Error())
}
Expand Down
12 changes: 6 additions & 6 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type httpEntrypoint struct {
path string
method string
reqFactory func() interface{}
invoker func(interface{}) (interface{}, error)
invoker func(interface{}, echo.Context) (interface{}, error)
}

// Service is a service define
Expand All @@ -42,26 +42,26 @@ func NewService(name string, metadata interface{}, opts ...ServiceOption) Servic
}

// WithAddGetHTTPEntrypoint add a http get service metadata
func WithAddGetHTTPEntrypoint(path string, reqFactory func() interface{}, invoker func(interface{}) (interface{}, error)) ServiceOption {
func WithAddGetHTTPEntrypoint(path string, reqFactory func() interface{}, invoker func(interface{}, echo.Context) (interface{}, error)) ServiceOption {
return withAddHTTPEntrypoint(path, echo.GET, reqFactory, invoker)
}

// WithAddPutHTTPEntrypoint add a http put service metadata
func WithAddPutHTTPEntrypoint(path string, reqFactory func() interface{}, invoker func(interface{}) (interface{}, error)) ServiceOption {
func WithAddPutHTTPEntrypoint(path string, reqFactory func() interface{}, invoker func(interface{}, echo.Context) (interface{}, error)) ServiceOption {
return withAddHTTPEntrypoint(path, echo.PUT, reqFactory, invoker)
}

// WithAddPostHTTPEntrypoint add a http post service metadata
func WithAddPostHTTPEntrypoint(path string, reqFactory func() interface{}, invoker func(interface{}) (interface{}, error)) ServiceOption {
func WithAddPostHTTPEntrypoint(path string, reqFactory func() interface{}, invoker func(interface{}, echo.Context) (interface{}, error)) ServiceOption {
return withAddHTTPEntrypoint(path, echo.POST, reqFactory, invoker)
}

// WithAddDeleteHTTPEntrypoint add a http post service metadata
func WithAddDeleteHTTPEntrypoint(path string, reqFactory func() interface{}, invoker func(interface{}) (interface{}, error)) ServiceOption {
func WithAddDeleteHTTPEntrypoint(path string, reqFactory func() interface{}, invoker func(interface{}, echo.Context) (interface{}, error)) ServiceOption {
return withAddHTTPEntrypoint(path, echo.DELETE, reqFactory, invoker)
}

func withAddHTTPEntrypoint(path, method string, reqFactory func() interface{}, invoker func(interface{}) (interface{}, error)) ServiceOption {
func withAddHTTPEntrypoint(path, method string, reqFactory func() interface{}, invoker func(interface{}, echo.Context) (interface{}, error)) ServiceOption {
return func(opt *serviceOptions) {
opt.httpEntrypoints = append(opt.httpEntrypoints, &httpEntrypoint{
path: path,
Expand Down

0 comments on commit a01ab85

Please sign in to comment.