Skip to content

Commit

Permalink
return Unimplemented error when registering service have stream method
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 862728f commit a0da87c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
16 changes: 2 additions & 14 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.

5 changes: 2 additions & 3 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.

11 changes: 10 additions & 1 deletion protoc-gen-grpc-gateway/gengateway/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,20 @@ 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) {
return status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport")
})
{{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 a0da87c

Please sign in to comment.