grpc-gateway | gRPC to JSON proxy generator following the gRPC HTTP spec | REST library

 by   grpc-ecosystem Go Version: v2.16.0 License: BSD-3-Clause

kandi X-RAY | grpc-gateway Summary

kandi X-RAY | grpc-gateway Summary

grpc-gateway is a Go library typically used in Web Services, REST, Swagger applications. grpc-gateway has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

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

            kandi-support Support

              grpc-gateway has a medium active ecosystem.
              It has 15595 star(s) with 2005 fork(s). There are 282 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 104 open issues and 932 have been closed. On average issues are closed in 55 days. There are 11 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of grpc-gateway is v2.16.0

            kandi-Quality Quality

              grpc-gateway has 0 bugs and 0 code smells.

            kandi-Security Security

              grpc-gateway has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              grpc-gateway code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              grpc-gateway is licensed under the BSD-3-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              grpc-gateway releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of grpc-gateway
            Get all kandi verified functions for this library.

            grpc-gateway Key Features

            No Key Features are available at this moment for grpc-gateway.

            grpc-gateway Examples and Code Snippets

            No Code Snippets are available at this moment for grpc-gateway.

            Community Discussions

            QUESTION

            PATCH API don't work on Google Cloud Run instance
            Asked 2021-Sep-16 at 11:08

            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:08

            This 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.

            Source https://stackoverflow.com/questions/69194259

            QUESTION

            How to Transcode HTTP DELETE with Request Body to gRPC
            Asked 2021-Jun-22 at 05:24

            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:12

            The protoc always has wired issues. Suggest use buf instead. And the config of buf.gen.yaml should like this and it works well:

            Source https://stackoverflow.com/questions/68071940

            QUESTION

            Error in generated code with protoc-gen-grpc-gateway
            Asked 2021-Jun-02 at 15:53

            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:40

            Ok 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.

            Source https://stackoverflow.com/questions/66142486

            QUESTION

            Handle REST requests in golang GRPC server
            Asked 2021-Apr-03 at 14:05

            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:05

            Looks 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

            Source https://stackoverflow.com/questions/66931877

            QUESTION

            How to connect to the gRPC service inside k8s cluster from outside gRPC client
            Asked 2021-Mar-21 at 07:12

            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:52

            You 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:

            Source https://stackoverflow.com/questions/66676139

            QUESTION

            GRPC-gateway default healthCheck support
            Asked 2021-Mar-16 at 10:06

            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:06

            So, 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.

            Source https://stackoverflow.com/questions/66246679

            QUESTION

            protoc generated grpc files and gateway files end up in different paths?
            Asked 2021-Feb-15 at 19:33

            I'm a bit baffled about this. File structure:

            ...

            ANSWER

            Answered 2021-Feb-15 at 19:33

            As 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.

            Source https://stackoverflow.com/questions/66171590

            QUESTION

            Import "google/api/annotations.proto" was not found or had errors. How do I add it as a dependency?
            Asked 2021-Feb-12 at 09:42

            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:42

            I 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

            Source https://stackoverflow.com/questions/66168350

            QUESTION

            gRPC GO Single Generic Service Handler
            Asked 2021-Jan-13 at 09:29

            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:29

            Got it to work, thanks to protoreflect

            Working sample without error handling

            Source https://stackoverflow.com/questions/65561125

            QUESTION

            Strict version on go.mod
            Asked 2020-Aug-12 at 05:06

            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:03

            If your git package has tag version, you can use this command:

            Source https://stackoverflow.com/questions/63369961

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install grpc-gateway

            The following instructions assume you are using Go Modules for dependency management. Use a tool dependency to track the versions of the following executable packages:. Run go mod tidy to resolve the versions. Install by running. This will place four binaries in your $GOBIN;. Make sure that your $GOBIN is in your $PATH.
            protoc-gen-grpc-gateway
            protoc-gen-openapiv2
            protoc-gen-go
            protoc-gen-go-grpc

            Support

            Generating JSON API handlers.Method parameters in the request body.Method parameters in the request path.Method parameters in the query string.Enum fields in the path parameter (including repeated enum fields).Mapping streaming APIs to newline-delimited JSON streams.Mapping HTTP headers with Grpc-Metadata- prefix to gRPC metadata (prefixed with grpcgateway-)Optionally emitting API definitions for OpenAPI (Swagger) v2.Setting gRPC timeouts through inbound HTTP Grpc-Timeout header.Partial support for gRPC API Configuration files as an alternative to annotation.Automatically translating PATCH requests into Field Mask gRPC requests. See the docs for more information.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/grpc-ecosystem/grpc-gateway.git

          • CLI

            gh repo clone grpc-ecosystem/grpc-gateway

          • sshUrl

            git@github.com:grpc-ecosystem/grpc-gateway.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular REST Libraries

            public-apis

            by public-apis

            json-server

            by typicode

            iptv

            by iptv-org

            fastapi

            by tiangolo

            beego

            by beego

            Try Top Libraries by grpc-ecosystem

            go-grpc-middleware

            by grpc-ecosystemGo

            go-grpc-prometheus

            by grpc-ecosystemGo

            grpc-health-probe

            by grpc-ecosystemGo

            polyglot

            by grpc-ecosystemJava

            grpc-opentracing

            by grpc-ecosystemPython