Skip to content

Commit

Permalink
Add details to stream error response.
Browse files Browse the repository at this point in the history
  • Loading branch information
johanbrandhorst committed Feb 27, 2018
1 parent 4eed2ba commit cd4034d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

PKG=github.com/grpc-ecosystem/grpc-gateway
GO_PLUGIN=bin/protoc-gen-go
GO_PLUGIN_PKG=github.com/golang/protobuf/protoc-gen-go
GO_PROTOBUF_REPO=github.com/golang/protobuf
GO_PLUGIN_PKG=$(GO_PROTOBUF_REPO)/protoc-gen-go
GO_PTYPES_ANY_PKG=$(GO_PROTOBUF_REPO)/ptypes/any
SWAGGER_PLUGIN=bin/protoc-gen-swagger
SWAGGER_PLUGIN_SRC= utilities/doc.go \
utilities/pattern.go \
Expand Down Expand Up @@ -91,7 +93,7 @@ $(GO_PLUGIN):
go build -o $@ $(GO_PLUGIN_PKG)

$(RUNTIME_GO): $(RUNTIME_PROTO) $(GO_PLUGIN)
protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP):. $(RUNTIME_PROTO)
protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I $(GOPATH)/src/$(GO_PTYPES_ANY_PKG) -I. --go_out=$(PKGMAP):. $(RUNTIME_PROTO)

$(OPENAPIV2_GO): $(OPENAPIV2_PROTO) $(GO_PLUGIN)
protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP):$(GOPATH)/src $(OPENAPIV2_PROTO)
Expand Down
1 change: 1 addition & 0 deletions runtime/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func streamChunk(result proto.Message, err error) map[string]proto.Message {
HttpCode: int32(httpCode),
Message: s.Message(),
HttpStatus: http.StatusText(httpCode),
Details: s.Proto().GetDetails(),
},
}
}
Expand Down
1 change: 1 addition & 0 deletions runtime/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func TestForwardResponseStream(t *testing.T) {
HttpCode: int32(httpCode),
Message: st.Message(),
HttpStatus: http.StatusText(httpCode),
Details: st.Proto().GetDetails(),
},
})
if err != nil {
Expand Down
46 changes: 29 additions & 17 deletions runtime/internal/stream_chunk.pb.go

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

3 changes: 3 additions & 0 deletions runtime/internal/stream_chunk.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ syntax = "proto3";
package grpc.gateway.runtime;
option go_package = "internal";

import "google/protobuf/any.proto";

// StreamError is a response type which is returned when
// streaming rpc returns an error.
message StreamError {
int32 grpc_code = 1;
int32 http_code = 2;
string message = 3;
string http_status = 4;
repeated google.protobuf.Any details = 5;
}

0 comments on commit cd4034d

Please sign in to comment.