I'm new in using gRPC with proto3, and I've used Transcoding HTTP/JSON to gRPC
to migrate existing http endpoints to grpc.
But I have http DELETE request with request body. I have tried following and got an error.
Grpc Endpoint :
rpc DeleteFile(DeleteFileRequest) returns (DeleteFileResponse) {
option (google.api.http) = {
delete: "/v2/file/delete/{path}"
body: "*"
};
}
protoc gererate command as below
protoc -I ./proto --go-grpc_out=. --go_out=. --grpc-gateway_out=. --openapiv2_out=./openapi ./proto/myapp.proto
Error I have Got
--grpc-gateway_out: must not set request body when http method is DELETE except allow_delete_body option is true
And then I have add --allow_delete_body=true
to my protoc command as below.
--allow_delete_body=true
error : Unknown flag: --allow_delete_body
--grpc-gateway_opt allow_delete_body=true
error : must not set request body when http method is DELETE except allow_delete_body option is true
grpc versions in my go.mod
github.com/grpc-ecosystem/grpc-gateway/v2 v2.3.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
google.golang.org/genproto v0.0.0-20210224155714-063164c882e6
google.golang.org/grpc v1.36.0
google.golang.org/protobuf v1.26.0
Would anyone kindly explain How I transcode HTTP DELETE to grpc with request body.
After spent time on web and trying with applying flags in different ways, I have found the working command for me. Thanks everyone help to resolve this.
This is the working command for me:
protoc -I ./proto --go-grpc_out=. --go_out=. --grpc-gateway_out=allow_delete_body=true:. --openapiv2_opt allow_delete_body=true --openapiv2_out=./openapi ./proto/myapp.proto