grpc-gateway | gRPC to JSON proxy generator following the gRPC HTTP spec | REST library
kandi X-RAY | grpc-gateway Summary
kandi X-RAY | grpc-gateway Summary
The gRPC-Gateway is a plugin of the Google protocol buffers compiler protoc. It reads protobuf service definitions and generates a reverse-proxy server which translates a RESTful HTTP API into gRPC. This server is generated according to the google.api.http annotations in your service definitions. This helps you provide your APIs in both gRPC and RESTful style at the same time.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of grpc-gateway
grpc-gateway Key Features
grpc-gateway Examples and Code Snippets
Community Discussions
Trending Discussions on grpc-gateway
QUESTION
I have cloud run services hosting GO OSB application implementing gRpc but exposing the http REST api's via grpc-gateway which uses cloud sql (mysql) as a DB. All the CRUD API's are responding fine except the PATCH one.
It's throwing the below error with http response code 503:
...ANSWER
Answered 2021-Sep-16 at 11:08This is fixed now !
Facing the due to handling of multiple protocols on the same port and one of the protocol matchers was causing the issue with PATCH API by returning Empty reply from server. So, done changes to the matchers and it worked.
RCA : Cmux HTTP1Fast Matcher only matches the methods in the HTTP request. This matcher is very optimistic: if it returns true, it does not mean that the request is a valid HTTP response. A correct but slower HTTP1 matcher, used "HTTP1" instead which scan the whole request up-to 4096 bytes but its bit slow.
QUESTION
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 :
...ANSWER
Answered 2021-Jun-22 at 04:12The protoc always has wired issues. Suggest use buf instead. And the config of buf.gen.yaml should like this and it works well:
QUESTION
I'm new to Protocol Buffers and gRPC stuff. Now I'm trying to build a client/server architecture with grpc + grpc-gateway in Go.
I tried to follow some examples but I always end up with the same problem.
After generating the code with protoc
i run go build
and I get this error:
ANSWER
Answered 2021-Feb-11 at 13:40Ok I solved the issue.
I had installed protoc
via snap and the stable channel had version 3.11.4
Now I upgraded to 3.14.0
and everything is working well.
QUESTION
Is it possible for a GRPC server written in golang to also handle REST requests?
I've found the grpc-gateway which enables turning an existing proto schema into a rest endpoint but I don't think that suits my needs.
I've written a GRPC server but I need to also serve webhook requests from an external service (like Github or Stripe). I'm thinking of writing a second REST based server to accept these webhooks (and possibly translate/forward them to the GRPC server) but that seems like a code-smell.
Ideally, I'd like for my GRPC server to also be able to, for example, handle REST requests at an endpoint like /webhook
or /event
but I'm not sure if that's possible and if it is how to configure it.
ANSWER
Answered 2021-Apr-03 at 14:05Looks like I asked my question before giving a large enough effort to resolve it my own. Here's an example of serving REST requests alongside GRPC requests
QUESTION
I have a gRPC server
running on port 9000 with gRPC-gateway
running on port 9080.
I can make request to my service with postman using the following link: ```http://cluster1.example.com/api/v1/namespaces/default/services/my-service:9080/proxy
How can I connect to my service from gRPC client
(on my local machine, which is outside of the cluster) using grpc.Dial()
?
Example:
...ANSWER
Answered 2021-Mar-19 at 23:52You should be able to connect to services in your k8s cluster from local with port forwarding:
kubectl port-forward --context -n svc/my-service 9000:9000
And then you just pass the gRPC target into Dial
with localhost and no scheme:
QUESTION
I'm using gRPC-gateway that works perfectly fine. But I need to have HealthCheck. I enabled DefaultHealthCheck and it works perfectly. TO make it possible, to check state over HTTP1.1 I found this solution https://github.com/salrashid123/grpc_health_proxy. ANd it works as well. But it's not the best solution to maintain 2 "gateways" + server by it self. So, my qestion is - if there is possible to enable defaultHealthCheck proxying in gRPC gateway? BEcause I don't understand how to implement this solution from docs https://grpc-ecosystem.github.io/grpc-gateway/docs/operations/health_check/
...ANSWER
Answered 2021-Mar-16 at 10:06So, the easiest way is to implement HealthCheck protocol procedures that basically return healthy state(200) and regenerate stubs with it, also gateway should be generated with it. Works perfectly fine for ALB AWS.
QUESTION
I'm a bit baffled about this. File structure:
...ANSWER
Answered 2021-Feb-15 at 19:33As per the comments you were using the module option (--go_opt=module=${module}
& --go-grpc_opt=module=${module}
) when generating the protobuf & gRPC files. The option you were using when generating the gateway files (--grpc-gateway_opt paths=source_relative
) uses a different algorithm to work out where to store the files; the fix being to use the module option - --grpc-gateway_opt module=${module}
.
Here is what the docs have to say about the three options (these specific options are for protobuf generation; the other generators have the same functionality but replace go_
with go-grpc_
/grpc-gateway_
):
- By default, the output file is placed in a directory named after the Go package's import path. For example, a file protos/foo.proto with the above go_package option results in a file named example.com/foo/bar/foo.pb.go.
- If the --go_opt=module=$PREFIX flag is given to protoc, the specified directory prefix is removed from the output filename. For example, a file protos/foo.proto with the go_package option "example.com/foo/bar" and the flag --go_opt=module=example.com/foo results in a file named bar/foo.pb.go.
- If the --go_opt=paths=source_relative flag is given to protoc, the output file is placed in the same relative directory as the input file. For example, the file protos/foo.proto results in a file named protos/foo.pb.go.
QUESTION
Following the docs on how to set up a gRPC gateway, I find myself stuck at step four of generating the grpc gateway.
Namely, things fall apart when the following line is added:
...ANSWER
Answered 2021-Feb-12 at 09:42I solved it one way by adding https://github.com/grpc-ecosystem/grpc-gateway/tree/master/third_party/googleapis
and its content to the root of my project.
Feels wrong, but apparently this is encouraged
QUESTION
I have used protoreflect to write http-to-gRPC-gateway. But I don't see any easy option to do the reverse - gRPC-to-HTTP-gateway. One of the idea is to expose GRPC to outside but use a custom gateway to invoke internal microservices via MessageQ to avoid loadbalancing, discovery service and may be convert GRPC streaming durable or use reflection to invoke method instead of using generated server stub
Below is what I got so far
...ANSWER
Answered 2021-Jan-13 at 09:29Got it to work, thanks to protoreflect
Working sample without error handling
QUESTION
My dependencies in go.mod file is always updated and i don't know why. I have go.mod like this
...ANSWER
Answered 2020-Aug-12 at 05:03If your git package has tag
version, you can use this command:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install grpc-gateway
protoc-gen-grpc-gateway
protoc-gen-openapiv2
protoc-gen-go
protoc-gen-go-grpc
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page