gRPC to JSON proxy generator following the gRPC HTTP spec

gRPC-Gateway

gRPC to JSON proxy generator following the gRPC HTTP spec

About

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.

Docs

You can read our docs at:

Testimonials

We use the gRPC-Gateway to serve millions of API requests per day, and have been since 2018 and through all of that, we have never had any issues with it.

- William Mill, Ad Hoc

Background

gRPC is great -- it generates API clients and server stubs in many programming languages, it is fast, easy-to-use, bandwidth-efficient and its design is combat-proven by Google. However, you might still want to provide a traditional RESTful JSON API as well. Reasons can range from maintaining backward-compatibility, supporting languages or clients that are not well supported by gRPC, to simply maintaining the aesthetics and tooling involved with a RESTful JSON architecture.

This project aims to provide that HTTP+JSON interface to your gRPC service. A small amount of configuration in your service to attach HTTP semantics is all that's needed to generate a reverse-proxy with this library.

Installation

The gRPC-Gateway requires a local installation of the Google protocol buffers compiler protoc v3.0.0 or above. Please install this via your local package manager or by downloading one of the releases from the official repository:

https://github.com/protocolbuffers/protobuf/releases

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:

// +build tools

package tools

import (
    _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway"
    _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2"
    _ "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
    _ "google.golang.org/protobuf/cmd/protoc-gen-go"
)

Run go mod tidy to resolve the versions. Install by running

$ go install \
    github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
    github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
    google.golang.org/protobuf/cmd/protoc-gen-go \
    google.golang.org/grpc/cmd/protoc-gen-go-grpc

This will place four binaries in your $GOBIN;

  • protoc-gen-grpc-gateway
  • protoc-gen-openapiv2
  • protoc-gen-go
  • protoc-gen-go-grpc

Make sure that your $GOBIN is in your $PATH.

Usage

  1. Define your gRPC service using protocol buffers

    your_service.proto:

     syntax = "proto3";
     package your.service.v1;
     option go_package = "github.com/yourorg/yourprotos/gen/go/your/service/v1";
     message StringMessage {
       string value = 1;
     }
    
     service YourService {
       rpc Echo(StringMessage) returns (StringMessage) {}
     }
  2. Generate gRPC stubs

    This step generates the gRPC stubs that you can use to implement the service and consume from clients:

    Here's an example of what a protoc command might look like to generate Go stubs:

    protoc -I . \
       --go_out ./gen/go/ --go_opt paths=source_relative \
       --go-grpc_out ./gen/go/ --go-grpc_opt paths=source_relative \
       your/service/v1/your_service.proto
  3. Implement your service in gRPC as usual

    1. (Optional) Generate gRPC stub in the other programming languages.

    For example, the following generates gRPC code for Ruby based on your/service/v1/your_service.proto:

    protoc -I . --ruby_out ./gen/ruby your/service/v1/your_service.proto
    
    protoc -I . --grpc-ruby_out ./gen/ruby your/service/v1/your_service.proto
    1. Add the googleapis-common-protos gem (or your language equivalent) as a dependency to your project.
    2. Implement your gRPC service stubs
  4. Generate reverse-proxy using protoc-gen-grpc-gateway

    At this point, you have 3 options:

    • no further modifications, use the default mapping to HTTP semantics (method, path, etc.)
      • this will work on any .proto file, but will not allow setting HTTP paths, request parameters or similar
    • additional .proto modifications to use a custom mapping
      • relies on parameters in the .proto file to set custom HTTP mappings
    • no .proto modifications, but use an external configuration file
      • relies on an external configuration file to set custom HTTP mappings
      • mostly useful when the source proto file isn't under your control
    1. Using the default mapping

    This requires no additional modification to the .proto file but does require enabling a specific option when executing the plugin. The generate_unbound_methods should be enabled.

    Here's what a protoc execution might look like with this option enabled:

       protoc -I . --grpc-gateway_out ./gen/go \
         --grpc-gateway_opt logtostderr=true \
         --grpc-gateway_opt paths=source_relative \
         --grpc-gateway_opt generate_unbound_methods=true \
         your/service/v1/your_service.proto
    1. With custom annotations

    Add a google.api.http annotation to your .proto file

    your_service.proto:

     syntax = "proto3";
     package your.service.v1;
     option go_package = "github.com/yourorg/yourprotos/gen/go/your/service/v1";
    +
    +import "google/api/annotations.proto";
    +
     message StringMessage {
       string value = 1;
     }
    
     service YourService {
    -  rpc Echo(StringMessage) returns (StringMessage) {}
    +  rpc Echo(StringMessage) returns (StringMessage) {
    +    option (google.api.http) = {
    +      post: "/v1/example/echo"
    +      body: "*"
    +    };
    +  }
     }

    You will need to provide the required third party protobuf files to the protoc compiler. They are included in this repo under the third_party/googleapis folder, and we recommend copying them into your protoc generation file structure. If you've structured your proto files according to something like the Buf style guide, you could copy the files into a top-level ./google folder.

    See a_bit_of_everything.proto for examples of more annotations you can add to customize gateway behavior and generated OpenAPI output.

    Here's what a protoc execution might look like:

       protoc -I . --grpc-gateway_out ./gen/go \
         --grpc-gateway_opt logtostderr=true \
         --grpc-gateway_opt paths=source_relative \
         your/service/v1/your_service.proto
    1. External configuration If you do not want to (or cannot) modify the proto file for use with gRPC-Gateway you can alternatively use an external gRPC Service Configuration file. Check our documentation for more information.

    Here's what a protoc execution might look like with this option enabled:

       protoc -I . --grpc-gateway_out ./gen/go \
         --grpc-gateway_opt logtostderr=true \
         --grpc-gateway_opt paths=source_relative \
         --grpc-gateway_opt grpc_api_configuration=path/to/config.yaml \
         your/service/v1/your_service.proto
  5. Write an entrypoint for the HTTP reverse-proxy server

    package main
    
    import (
      "context"
      "flag"
      "net/http"
    
      "github.com/golang/glog"
      "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
      "google.golang.org/grpc"
    
      gw "github.com/yourorg/yourrepo/proto/gen/go/your/service/v1/your_service"  // Update
    )
    
    var (
      // command-line options:
      // gRPC server endpoint
      grpcServerEndpoint = flag.String("grpc-server-endpoint",  "localhost:9090", "gRPC server endpoint")
    )
    
    func run() error {
      ctx := context.Background()
      ctx, cancel := context.WithCancel(ctx)
      defer cancel()
    
      // Register gRPC server endpoint
      // Note: Make sure the gRPC server is running properly and accessible
      mux := runtime.NewServeMux()
      opts := []grpc.DialOption{grpc.WithInsecure()}
      err := gw.RegisterYourServiceHandlerFromEndpoint(ctx, mux,  *grpcServerEndpoint, opts)
      if err != nil {
        return err
      }
    
      // Start HTTP server (and proxy calls to gRPC server endpoint)
      return http.ListenAndServe(":8081", mux)
    }
    
    func main() {
      flag.Parse()
      defer glog.Flush()
    
      if err := run(); err != nil {
        glog.Fatal(err)
      }
    }
  6. (Optional) Generate OpenAPI definitions using protoc-gen-openapiv2

    protoc -I . --openapiv2_out ./gen/openapiv2 --openapiv2_opt logtostderr=true your/service/v1/your_service.proto

    Note that this plugin also supports generating OpenAPI definitions for unannotated methods; use the generate_unbound_methods option to enable this.

Video intro

This GopherCon UK 2019 presentation from our maintainer @JohanBrandhorst provides a good intro to using the gRPC-Gateway. It uses the following boilerplate repo as a base: https://github.com/johanbrandhorst/grpc-gateway-boilerplate.

Parameters and flags

During code generation with protoc, flags to gRPC-Gateway tools must be passed through protoc using one of 2 patterns:

  • as part of the --_out protoc parameter: --_out=:
--grpc-gateway_out=logtostderr=true,repeated_path_param_separator=ssv:.
--openapiv2_out=logtostderr=true,repeated_path_param_separator=ssv:.
  • using additional --_opt parameters: --_opt=[,]*
--grpc-gateway_opt logtostderr=true,repeated_path_param_separator=ssv
# or separately
--grpc-gateway_opt logtostderr=true --grpc-gateway_opt repeated_path_param_separator=ssv

--openapiv2_opt logtostderr=true,repeated_path_param_separator=ssv
# or separately
--openapiv2_opt logtostderr=true --openapiv2_opt repeated_path_param_separator=ssv

protoc-gen-grpc-gateway supports custom mapping from Protobuf import to Golang import paths. They are compatible with the parameters with the same names in protoc-gen-go.

In addition, we also support the request_context parameter in order to use the http.Request's Context (only for Go 1.7 and above). This parameter can be useful to pass the request-scoped context between the gateway and the gRPC service.

protoc-gen-grpc-gateway also supports some more command line flags to control logging. You can give these flags together with the parameters above. Run protoc-gen-grpc-gateway --help for more details about the flags.

Similarly, protoc-gen-openapiv2 supports command-line flags to control OpenAPI output (for example, json_names_for_fields to output JSON names for fields instead of protobuf names). Run protoc-gen-openapiv2 --help for more flag details. Further OpenAPI customization is possible by annotating your .proto files with options from openapiv2.proto - see a_bit_of_everything.proto for examples.

More examples

More examples are available under the examples directory.

  • proto/examplepb/echo_service.proto, proto/examplepb/a_bit_of_everything.proto, proto/examplepb/unannotated_echo_service.proto: service definition
    • proto/examplepb/echo_service.pb.go, proto/examplepb/a_bit_of_everything.pb.go, proto/examplepb/unannotated_echo_service.pb.go: [generated] stub of the service
    • proto/examplepb/echo_service.pb.gw.go, proto/examplepb/a_bit_of_everything.pb.gw.go, proto/examplepb/uannotated_echo_service.pb.gw.go: [generated] reverse proxy for the service
    • proto/examplepb/unannotated_echo_service.yaml: gRPC API Configuration for unannotated_echo_service.proto
  • server/main.go: service implementation
  • main.go: entrypoint of the generated reverse proxy

To use the same port for custom HTTP handlers (e.g. serving swagger.json), gRPC-Gateway, and a gRPC server, see this example by CoreOS (and its accompanying blog post).

Features

Supported

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

No plan to support

But patches are welcome.

  • Method parameters in HTTP headers.
  • Handling trailer metadata.
  • Encoding request/response body in XML.
  • True bi-directional streaming.

Mapping gRPC to HTTP

  • How gRPC error codes map to HTTP status codes in the response.
  • HTTP request source IP is added as X-Forwarded-For gRPC request header.
  • HTTP request host is added as X-Forwarded-Host gRPC request header.
  • HTTP Authorization header is added as authorization gRPC request header.
  • Remaining Permanent HTTP header keys (as specified by the IANA here are prefixed with grpcgateway- and added with their values to gRPC request header.
  • HTTP headers that start with 'Grpc-Metadata-' are mapped to gRPC metadata (prefixed with grpcgateway-).
  • While configurable, the default {un,}marshaling uses protojson.

Contribution

See CONTRIBUTING.md.

License

gRPC-Gateway is licensed under the BSD 3-Clause License. See LICENSE.txt for more details.

Comments
  • Merge v2 into master

    Merge v2 into master

    Draft change of merging v2 into master. Probably have to freeze v2 and master from now until I can merge this. I'm going to come back to this and update things that are missing/incorrect before we can make the release.

    Fixes #1223

  • Support HttpRule with field response

    Support HttpRule with field response

    This PR adds support optional response_body field for google.api.HttpRule. Also see PR: https://github.com/google/go-genproto/pull/87 and https://github.com/googleapis/googleapis/pull/512

    This version of code can work with current HttpRule implementation and with forked implementation with new field. This implementation does not break existing code.

    Also allow_repeated_fields_in_body flag added to make it possible using repeated fields in body and response_body. This flag can be used for slices in request and response.

    Also flag json_name_in_swgdef added to make it possible to use Field.GetJsonName() instead of Field.GetName() for generating swagger definitions. See: https://github.com/grpc-ecosystem/grpc-gateway/pull/681 for more info.

  • v2 release planning

    v2 release planning

    I figured we should have an issue to track the outstanding work for tagging a first stable v2 version of the gateway and switching the default branches. I've looked through the issue tracker and I think these are some of the issues we want to tackle:

    • [x] Issues mentioned in https://github.com/grpc-ecosystem/grpc-gateway/pull/546, including:
      • [x] Emitting defaults (https://github.com/grpc-ecosystem/grpc-gateway/issues/233)
      • [x] Using jsonpb marshaller by default
      • [x] Changing the output of errors to match the JSON representation of a gRPC status (https://github.com/grpc-ecosystem/grpc-gateway/issues/1098).
      • [x] Adopt correct behaviour for custom verbs (see https://github.com/grpc-ecosystem/grpc-gateway/issues/224#issuecomment-426091809).
      • [x] Change default JSON marshalling to use camelCase (https://github.com/grpc-ecosystem/grpc-gateway/pull/540) (and update swagger: https://github.com/grpc-ecosystem/grpc-gateway/issues/375)
    • [x] Switch to using the new Go protobuf stack (depends on https://github.com/grpc/grpc-go/pull/3453) (https://github.com/grpc-ecosystem/grpc-gateway/pull/1165 is the first part of this). #1147 #1719
    • [x] Use rules_go version which support APIv2 well known types (https://github.com/bazelbuild/rules_go/issues/2514)
    • [x] Minimize public API per https://github.com/grpc-ecosystem/grpc-gateway/pull/1146
    • [x] Rename swagger to openapi (https://github.com/grpc-ecosystem/grpc-gateway/issues/675)
    • [x] Consolidate error handler configuration.
    • [x] Make HTTPBodyMarshaler behaviour the default
    • [x] Remove runtime.DisallowUnknownFields

    I will update this issue as we find more things we want to have in a v2 release. I've also updated the v2 milestone: https://github.com/grpc-ecosystem/grpc-gateway/milestone/3.

  • add patch behavior

    add patch behavior

    this addresses #379

    If a binding is mapped to patch and the request message has exactly one FieldMask message in it, additional code is rendered for the gateway handler that will populate the FieldMask based on the request body.

    This handles two scenarios: The FieldMask is hidden from the REST request (as in the UpdateV2 example). In this case, the FieldMask is updated from the request body and set in the gRPC request message.

    The FieldMask is exposed to the REST request (as in the PatchWithFieldMaskInBody example). For this case, a check is made as to whether the FieldMask is nil/empty prior to populating with the request body. If it's not nil, then it converts the FieldMask paths from the REST (snake_case) to gRPC (PascalCase) format. Otherwise, it acts like the previous case.

    Additional comments of interest are inline on this PR.

  • 404s using colons in the middle of the last path segment

    404s using colons in the middle of the last path segment

    I have the following endpoint and user_ids of the format "user:"

      rpc GetUser(GetUserRequest) returns (GetUserResponse) {
        option (google.api.http) = {
          get: "/v0/users/{user_id}"
        };
      };
    

    I'm getting 404 status code and it doesn't hit my GetUser handler when I call this endpoint with user_ids of the format above. However, if I call the endpoint with a user_id that doesn't have a colon it (e.g. "user123") it does hit my GetUser handler. Url encoding the colon doesn't work either.

    What's even more interesting is if I add another colon to the end of the path, grpc-gateway parses the user_id into the correct format that I want. ("/v0/users/user:123:" -> user_id = "user:123"). Given this data point, I believe grpc-gateway is treating colons differently in the last path segment.

    For example here: https://github.com/grpc-ecosystem/grpc-gateway/blob/master/protoc-gen-grpc-gateway/httprule/parse.go#L86 it strips off the last colon in the segment. Though this looks like the rule for parsing the endpoint path definition and not what is being used to parse incoming requests.

  • Add a register, so that the gRPC service can be invoked in-process to provide a HTTP server.

    Add a register, so that the gRPC service can be invoked in-process to provide a HTTP server.

    sometimes we don't need the HTTP gateway to be a RPC. just convert the gRPC service to an HTTP service. this reduces one remote call.

    example code

    func main() {
    	s := grpc.NewServer(
    	)
    	srv := service{}
    	pb.RegisterExampleServiceServer(s, &srv)
    
    	ctx := context.Background()
    	ctx, cancel := context.WithCancel(ctx)
    	defer cancel()
    
    	mux := runtime.NewServeMux()
    	err := pb.RegisterExampleServiceHandlerServer(ctx, mux, &srv)
    	if err != nil {
    		log.Panic(err)
    	}
    
    	if err := http.ListenAndServe(serveAddr, mux); err != nil {
    		log.Fatalf("http failed to serve: %v", err)
    	}
    }
    
  • Properly omit wrappers and google.protobuf.empty from swagger definitions

    Properly omit wrappers and google.protobuf.empty from swagger definitions

    • swaggerSchemaObject.Properties is now optional (pointer), because google.protobuf.Empty requires us to set Properties{} instead of nil, because this equals in Swagger to an empty JSON object (which is exactly what Empty represents and how the gateway treats it). If it's not a pointer, we can't distinguish between "not set" (in most cases, we don't want Properties to be set, instead usually just .Ref is set), and "set to an empty value e.g. Properties{} with length 0). We don't want Properties{} to occur except for specific cases, e.g. for Empty.
    • Wrappers and Empty are not rendered as definitions, now also for RPC Method input/output. instead, all necessary schema information is provided "in-line" via schema.type and schema.properties.
    • Empty is now omitted as well if it's input/output of a RPC Method.
  • Support go modules

    Support go modules

    Steps you follow to reproduce the error:

    1. Using go1.11 outside of go path
    2. Run go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway

    Returns

    go: finding github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway latest
    
    # github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor
    
    ../../go/pkg/mod/github.com/grpc-ecosystem/[email protected]/protoc-gen-grpc-gateway/descriptor/services.go:146:49: opts.ResponseBody undefined (type *annotations.HttpRule has no field or method ResponseBody)
    -->
    

    What did you expect to happen instead: Successfully added to mod file

    It seems like it's able to find the latest version 1.5.0, but then isn't up to date? The error that's output seems to be what was fixed with #731

  • use Go templates in protofile comments

    use Go templates in protofile comments

    Introduce GO Templates into proto comments to allow more advanced documentation such as from external (markdown) files and automatically generated content based on the proto definitions.

    For example: The comments in this proto file:

    syntax = "proto3";
    
    package LoginTest;
    
    import "google/api/annotations.proto";
    
    service LoginService {
    
    // Logout
    // 
    // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service.
    // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}".
    // 
    // ## {{.RequestType.Name}}
    // | Field ID    | Name      | Type                                                       | Description                  |
    // | ----------- | --------- | ---------------------------------------------------------  | ---------------------------- | {{range .RequestType.Fields}}
    // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}}  
    //  
    // ## {{.ResponseType.Name}}
    // | Field ID    | Name      | Type                                                       | Description                  |
    // | ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | {{range .ResponseType.Fields}}
    // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}}  
    rpc Logout (LogoutRequest) returns (LogoutReply) {
      option (google.api.http) = {
        post: "/v1/example/ekko"
        body: "*"
        additional_bindings {
          post: "/test/test/test"
        }
        };
      }
    }
    
    message LogoutRequest {
      // This field only contains this title
      string timeoflogout = 1;
      // This is the title
      //
      // This is the "Description" of field test
      // you can use as many newlines as you want
      //
      //
      // it will still format the same in the table
      int32 test = 2;
      // Array title
      repeated string stringarray = 3;
    }
    
    message LogoutReply {
      // Message that displays whether the logout was succesful or not
      string message = 1;
    }
    

    would generate the following documentation in Swagger UI:

    image

    or when imported in Postman:

    image

  • protoc-gen-swagger: should well known types be nullable

    protoc-gen-swagger: should well known types be nullable

    • OpenAPI 3.0 support nullable [link] field to define schema can be null value.
    • go-swagger support vendor extensions for x-nullable [link]

    Should protoc-gen-swagger convert well know types to nullable type?

  • Generate Swagger with Unique Operation IDs

    Generate Swagger with Unique Operation IDs

    This PR prepends the service name to the method name to generate unique operation IDs. Prior to this change, the swagger generator would produce spec non-compliant swagger when multiple services had shared method names. This is quite problematic for generic CRUD services with method names like Create, Delete, etc.

  • fix: JSON examples in YAML output [#3095]

    fix: JSON examples in YAML output [#3095]

    References to other Issues or PRs

    Fixes #3095

    Have you read the Contributing Guidelines?

    Yes.

    Brief description of what is fixed or changed

    Support JSON examples in YAML output, add a test.

    Other comments

    image

  • The http header mapping behavior is different from documentation

    The http header mapping behavior is different from documentation

    📚 Documentation

    The documentation says:

    HTTP headers that start with 'Grpc-Metadata-' are mapped to gRPC metadata (prefixed with grpcgateway-).

    I expected the metadata being prefixed with grpcgateway-. However they are not. After digging into the code, it turns out that the code doesn't add the prefix to the metadata:

    // DefaultHeaderMatcher is used to pass http request headers to/from gRPC context. This adds permanent HTTP header
    // keys (as specified by the IANA) to gRPC context with grpcgateway- prefix. HTTP headers that start with
    // 'Grpc-Metadata-' are mapped to gRPC metadata after removing prefix 'Grpc-Metadata-'.
    func DefaultHeaderMatcher(key string) (string, bool) {
    	key = textproto.CanonicalMIMEHeaderKey(key)
    	if isPermanentHTTPHeader(key) {
    		return MetadataPrefix + key, true
    	} else if strings.HasPrefix(key, MetadataHeaderPrefix) {
    		return key[len(MetadataHeaderPrefix):], true
    	}
    	return "", false
    }
    

    Since our code base relies on this behavior, fixing the code may break existing users. So maybe it's good to just change the documentation to align with the code.

  • build(deps): bump json5 and webpack-stream in /examples/internal/browser

    build(deps): bump json5 and webpack-stream in /examples/internal/browser

    Removes json5. It's no longer used after updating ancestor dependency webpack-stream. These dependencies need to be updated together.

    Removes json5

    Updates webpack-stream from 3.2.0 to 7.0.0

    Commits
    • 30a6da0 v7.0.0
    • c2d19fd semistandard fixes
    • 7805d59 Remove config.watch setting re-introduced from my bad merging
    • 6395f19 Merge branch 'master' of github.com:shama/webpack-stream
    • 7c24e86 Merge pull request #212 from azt3k/master
    • 3fc84f0 Merge branch 'master' into master
    • 027135e Update comments to indicate it works with webpack 4 and 5
    • bb7cd85 Merge branch 'master' of github.com:shama/webpack-stream
    • 3287835 Merge pull request #214 from the-ress/watch-message
    • 141e063 Update watch for gulp >= 4
    • Additional commits viewable in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
  • Support field extensions with use_allof_for_refs

    Support field extensions with use_allof_for_refs

    References to other Issues or PRs

    Have you read the Contributing Guidelines?

    Yes

    Brief description of what is fixed or changed

    Allow extensions to be used with the recently added AllOf feature

    Other comments

  • protoc-gen-openapiv2: YAML output of examples is wrong

    protoc-gen-openapiv2: YAML output of examples is wrong

    🐛 Bug Report

    Hello, this is my first issue, I just try using protoc-gen-openapiv2 and write some proto but I found when write the example of response and render it, the output will render []byte.

    Sorry for my english.

    To Reproduce

    (Write your steps here:)

    1. Write a example like this one:
    examples: {
            key: "application/json"
            value: "{\"value\": \"the input value\"}"
          }
    
    1. After generate, the value is like []byte:
    image

    My example proto

    service Signup {
        rpc Signup (SignupRequest) returns (SampleResponse) {
          option (google.api.http) = {
            post: "/v1/signup",
            body: "*"
          };
          option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
            consumes: [""]
            responses: {
                key: "200"
                value: {
                    description: "Success"
                }
            }
            responses: {
                key: "500"
                value: {
                    description: "internal Server Error",
                    schema: {
                      json_schema: {
                        ref: ".Error";
                      }
                    }
                    examples: {
                      key: "application/json"
                      value: "{\"value\": \"the input value\"}"
                    }
                }
            }
          };
        }
    }
    

    i;m using buf to generate, this is my configuration:

    version: v1
    managed:
      enabled: true
      go_package_prefix:
        default: github.com/example/example-proto
    plugins:
      - remote: buf.build/grpc-ecosystem/plugins/openapiv2:v2.15.0
        opt:
          - merge_file_name=config
          - allow_merge
          - use_allof_for_refs
        out: ../../gen/openapiv2
    
  • Add support for unmarshaling a HTTPBody as raw data.

    Add support for unmarshaling a HTTPBody as raw data.

    It would be very nice if there is a type which can receive raw binary data as body, and all according metadata via headers (Content-Type video/mp4).

    Browsers of today can send real binary data (const binaryData = new Uint8Array(buffer);).

    Curl scripts also (curl --data-binary "@filepath").

    This would reduce the transferred data size by 33%.

    I refer to HttpBody, because this type is only usable as a "root" response type in a transcoded context, why not bidirectional?

    Originally posted by @veith in https://github.com/grpc-ecosystem/grpc-gateway/issues/1781#issuecomment-1364121185

Golang 微服务框架,支持 grpc/http,支持多种注册中心 etcd,consul,mdns 等

一个用于构建分布式系统的工具集或者轻框架,支持 grpc 和 http ,支持多种注册中心 consul ,etcd , mdns 等。

Nov 30, 2022
Solution & Framework for JSON-RPC over HTTP

JROH Solution & Framework for JSON-RPC over HTTP Why not OpenAPI? OpenAPI addresses the definition of RESTful APIs, when it comes to JSON-RPCs, some i

Mar 13, 2022
Social previews generator as a microservice.
Social previews generator as a microservice.

ogimgd Social previews generator as a microservice. Can be used to generate images for og:image meta-tag. It runs as an HTTP server with a single endp

Sep 17, 2022
OpenAPI Client and Server Code Generator

This package contains a set of utilities for generating Go boilerplate code for services based on OpenAPI 3.0 API definitions

Dec 2, 2022
Proof-of-concept SLSA provenance generator for GitHub Actions

SLSA GitHub Actions Demo A proof-of-concept SLSA provenance generator for GitHub Actions. Background SLSA is a framework intended to codify and promot

Nov 4, 2022
A db proxy for distributed transaction, read write splitting and sharding! Support any language! It can be deployed as a sidecar in a pod.
A db proxy for distributed transaction, read write splitting and sharding! Support any language! It can be deployed as a sidecar in a pod.

DBPack DBPack means a database cluster tool pack. It can be deployed as a sidecar in a pod, it shields complex basic logic, so that business developme

Dec 29, 2022
Go gRPC RabbitMQ email microservice

Go, RabbitMQ and gRPC Clean Architecture microservice ?? ??‍?? Full list what has been used: GRPC - gRPC RabbitMQ - RabbitMQ sqlx - Extensions to data

Dec 29, 2022
Sample cloud-native application with 10 microservices showcasing Kubernetes, Istio, gRPC and OpenCensus.
Sample cloud-native application with 10 microservices showcasing Kubernetes, Istio, gRPC and OpenCensus.

Online Boutique is a cloud-native microservices demo application. Online Boutique consists of a 10-tier microservices application. The application is

Dec 31, 2022
Automatic Service Mesh and RPC generation for Go micro services, it's a humble alternative to gRPC with Istio.
Automatic Service Mesh and RPC generation for Go micro services, it's a humble alternative to gRPC with Istio.

Mesh RPC MeshRPC provides automatic Service Mesh and RPC generation for Go micro services, it's a humble alternative to gRPC with Istio. In a nutshell

Aug 22, 2022
drpc is a lightweight, drop-in replacement for gRPC
drpc is a lightweight, drop-in replacement for gRPC

drpc is a lightweight, drop-in replacement for gRPC

Jan 8, 2023
Microservice Boilerplate for Golang with gRPC and RESTful API. Multiple database and client supported
Microservice Boilerplate for Golang with gRPC and RESTful API. Multiple database and client supported

Go Microservice Starter A boilerplate for flexible Go microservice. Table of contents Features Installation Todo List Folder Structures Features: Mult

Jul 28, 2022
Go microservices with REST, and gRPC using BFF pattern.
Go microservices with REST, and gRPC using BFF pattern.

Go microservices with REST, and gRPC using BFF pattern. This repository contains backend services. Everything is dockerized and ready to

Jan 4, 2023
A gRPC API for Warhammer Age of Sigmar

Warhammer ?? A gRPC API for Warhammer Age of Sigmar Intro ℹ️ Skip to Quick Start What is this? An API for creating, reading, deleting, and updating a

Oct 26, 2021
一款依赖 etcd 作为注册中心的 Golang 轻量级 GRPC 框架
一款依赖 etcd 作为注册中心的 Golang 轻量级 GRPC 框架

Golang 微服务 GRPC 标准框架(轻量级) 特性介绍 可使用 etcd 集群或单节点作为注册中心 客户端请求服务端自带负载均衡 服务端启动后自动向 etcd 注册,默认每 10s 进行一次心跳续租 自带优雅停止 panic recover 服务端无需指定启动端口,当然你也可以通过 WithP

Nov 11, 2021
Testing ground for CRUD backend using Golang, gRPC, protobufs

blog-example-service Simple example CRUD backend using Golang, gRPC, and protobufs. Using with MongoDB as the database (default) You will need a Mongo

Dec 16, 2021
Just a quick demo of how you can use automatically generated protobuffer and gRPC code from buf.build

buf.build demo The purpose of this repository is to demonstrate how to use the services offered by buf.build for hosting protobuffer definitions and a

Jan 4, 2022
Golang Microservice making use of protobuf and gRPC as the underlying transport protocol.

Go-Microservices Golang Microservice making use of protobuf and gRPC as the underlying transport protocol. I will be building a generic microservice,

Jan 5, 2022
Authentication-microservice - Microservice for user authentication built with golang and gRPC

Authentication-microservice - Microservice for user authentication built with golang and gRPC

May 30, 2022
Article - Golang mysql rest grpc

To bring up the project run: To bring up database on docker in root folder run:

Sep 26, 2022