diff --git a/http.go b/http.go index 6993850..7f76760 100644 --- a/http.go +++ b/http.go @@ -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()) } diff --git a/service.go b/service.go index 34c7c94..aa4c498 100644 --- a/service.go +++ b/service.go @@ -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 @@ -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,