Reputation: 5053
I have a restful application made in Go, now I have to make this app also serve as gRPC server (I already created the needed files). I have the restful endpoints running in the port 8000, now I have the next questions:
Upvotes: 2
Views: 1669
Reputation: 6628
Yes! If you want to serve gRPC as a RESTful service, there is a gRPC Gateway project that allows you to annotate your Protos, so they can be served over REST.
Yes, but this gets a little trickier. The gRPC server in Go implements net/http.Handler, so you can add it to your existing HTTP server. Getting the URL paths to match is something you'll need to play around with, but it is certainly possible.
I don't think there is any recommended approach. It depends mainly on environment constraints (such as if there are proxies, how you encrypt your connections, etc.).
Initialize the gRPC Server first, and then add it to the HTTP server.
Upvotes: 2