Skip to content

Commit

Permalink
return error when streaming method call
Browse files Browse the repository at this point in the history
  • Loading branch information
hb-chen authored and johanbrandhorst committed Aug 28, 2019
1 parent a0da87c commit 47c6a88
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 14 deletions.
58 changes: 56 additions & 2 deletions examples/proto/examplepb/flow_combination.pb.gw.go

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

14 changes: 12 additions & 2 deletions examples/proto/examplepb/stream.pb.gw.go

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

14 changes: 4 additions & 10 deletions protoc-gen-grpc-gateway/gengateway/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,20 +547,14 @@ func local_request_{{.Method.Service.GetName}}_{{.Method.GetName}}_{{.Index}}(ct
// UnaryRPC :call {{$svc.GetName}}Server directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
func Register{{$svc.GetName}}{{$.RegisterFuncSuffix}}Server(ctx context.Context, mux *runtime.ServeMux, server {{$svc.GetName}}Server, opts []grpc.DialOption) error {
{{$streaming := 0}}
{{range $m := $svc.Methods}}
{{if or $m.GetClientStreaming $m.GetServerStreaming}}
{{$streaming = 1}}
{{end}}
{{end}}
{{if eq $streaming 1}}
return status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport")
{{end}}
{{range $m := $svc.Methods}}
{{range $b := $m.Bindings}}
{{if or $m.GetClientStreaming $m.GetServerStreaming}}
mux.Handle({{$b.HTTPMethod | printf "%q"}}, pattern_{{$svc.GetName}}_{{$m.GetName}}_{{$b.Index}}, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport")
_, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
})
{{else}}
mux.Handle({{$b.HTTPMethod | printf "%q"}}, pattern_{{$svc.GetName}}_{{$m.GetName}}_{{$b.Index}}, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
Expand Down

0 comments on commit 47c6a88

Please sign in to comment.