Skip to content

Commit

Permalink
fix(genrest): pass http request context to service handler (#1088)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahdietz authored May 26, 2022
1 parent ef95407 commit bad9b6b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions util/genrest/goviewcreator.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func NewView(model *gomodel.Model) (*goview.View, error) {
file.P("")

fileImports := map[string]string{
"context": "",
"net/http": "",
"github.com/googleapis/gapic-showcase/util/genrest/resttools": "",
"github.com/gorilla/mux": "gmux",
Expand Down Expand Up @@ -213,7 +212,7 @@ func NewView(model *gomodel.Model) (*goview.View, error) {

} else { // regular unary call
// TODO: In the future, we may want to redirect all REST-endpoint requests to the gRPC endpoint so that the gRPC-registered observers get invoked.
source.P(" %s, err := backend.%sServer.%s(context.Background(), %s)", handler.ResponseVariable, service.ShortName, handler.GoMethod, handler.RequestVariable)
source.P(" %s, err := backend.%sServer.%s(r.Context(), %s)", handler.ResponseVariable, service.ShortName, handler.GoMethod, handler.RequestVariable)
source.P(" if err != nil {")
source.P(" backend.ReportGRPCError(w, err)")
source.P(" return")
Expand Down

0 comments on commit bad9b6b

Please sign in to comment.