Indeed, the gRPC-gateway supports server side streaming through XHR (newline delimited). However, I'm not sure we can use that bidi proxy with my gRPC-web proxy as they both assume they own all websocket upgrades sent. Might be possible to split traffic with headers but I haven't tested these running together. Travis's proxy was what inspired me to write the websocket functionality into gRPC-web.
As for building this into gRPC-web, it'd be a matter of implementing the translation in the proxy. Long term, as gRPC-web approaches the official gRPC protocol this translation will become someone else's job, as the need for the proxy disappears. So I don't think this functionality will be built into existing proxies, and we should just redirect traffic based on headers. If I find the time I can try to modify my example to respond in JSON to requests providing the application/grpc-web+json content type header. Johan On Fri, Dec 29, 2017, 21:19 Eric Drechsel <[email protected]> wrote: > I can vouch for grpc-gateway being a solid solution for JSON-based access. > I hope this functionality gets rolled into grpc-web. > > If you want bidi streaming support for JSON you can add > https://github.com/tmc/grpc-websocket-proxy. IDT grpc-gateway supports > fetch-based streaming currently, but it likely will as soon as browsers do. > Long term, I really hope grpc-web grows JSON support. > > > > On Fri, Dec 29, 2017 at 10:55 AM, Johan Brandhorst < > [email protected]> wrote: > >> This could be nice. >>> >>> But if we get addicted to this, does it also speak JSON for people who >>> want to speak JSON? I'm afraid we'd either let our JSON rot, or we'd have >>> twice the maintenance cost. Ideally we'd get both for free, with one >>> sufficiently-annotated proto file. >>> >> >> While the gRPC-Web spec >> <https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md#protocol-differences-vs-grpc-over-http2>mentions >> JSON content types, I don't think this is currently possible in the >> gRPC-Web client. However, we could deploy a gRPC-gateway >> <https://github.com/grpc-ecosystem/grpc-gateway/> on a handler and split >> traffic based on headers and HTTP version. The gRPC-gateway uses the Google >> annotations.proto annotations to map gRPC service methods to endpoints. >> So we could bake in a gRPC-gateway and a gRPC server and expose both JSON >> and gRPC and gRPC-web on the same port, with the interfaces all using the >> same protofile as the source of truth. >> >> I could potentially bake this part into the current POC if it would be of >> interest. >> >> Johan >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Camlistore" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > best, Eric > eric.pdxhub.org <http://pdxhub.org/people/eric> > > -- > You received this message because you are subscribed to the Google Groups > "Camlistore" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Camlistore" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
