helpful-rocket-63313
10/16/2023, 4:56 PMgrpc-gateway
, https://github.com/grpc-ecosystem/grpc-gateway can generate a REST API for grpc services, but it has to be generated in go. This means changing/modifying https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/codegen/protobuf/go/rules.py codegen.protobuf.go
.
My current approach is, to copy the official source code of codegen.go.protobuf.rules to local pants_plugin
, and use this custom code generator. For this custom plugin, I am generating a local go.mod
and go.sum
which includes grpc-gateway
packages, and any relevant changes like downloading binaries (https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/codegen/protobuf/go/rules.py#L596) or adding plugin here https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/codegen/protobuf/go/rules.py#L500
Do you think it's the right approach ? If yes, then do you think this can/should be added to official code generator(controlled by some variable, like generate_grpc_gateway)? If yes, then once I have my local plugging stabilized, I can create a PR.gorgeous-winter-99296
10/16/2023, 7:42 PMgrpc-gateway
, but the general approach sounds sensible. I guess this would be a flag (go_grpc_gateway
?) on the protobuf_sources
? How does this interop with the regular grpc generation, if at all? I.e. if someone where to set go_grpc_gateway
and grpc
both to true, does that create a package with both kinds of services?