How can I add JSON-based GRPC services, a.k.a unframed gRPC-JSON?
See original GitHub issueI wonder if it is possible to auto add Json based service whenever a GRPC service is added to server. This will helps organizations who want to migrate from Json base Rest apis server to Armeria-Grpc server.
For example, we have a grpc SomeGrpcService which have a rpc SayHello
. And the path for SayHello GRPC service could be something like my.package/SomeGrpcService/SayHello
.
With the following config, we could auto add a Rest version SayHello service while binding to the path of my.package/SomeGrpcService/Rest/SayHello
.
serverBuilder
.service(
(ServiceWithPathMappings<HttpRequest, HttpResponse>)
new GrpcServiceBuilder()
// This is the config of new proposed function
.enableRestService(true)
.addService(someGrpcService)
.supportedSerializationFormats(GrpcSerializationFormats.values())
.build()
)
Then, by default, we assume the GRPC request and response of SayHello service is SayHelloRequest and SayHelloResponse. And to serve all client Json based Rest requests to the path of my.package/SomeGrpcService/Rest/SayHello
via GRPC SayHello service by adding a layer which using @chokoswitch 's Buffer <-> JSON marshaller to convert to/from Json and GRPC request and response.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (5 by maintainers)
Top GitHub Comments
Yeah - the format is determined by the content type of the request. In fact, this is currently being the debug form for gRPC.
There is a bit of documentation here, if there’s anything not clear let me know so we can fix it 😃
http://line.github.io/armeria/server-grpc.html#unframed-requests
Updated the title of this issue to make it an answered question.