From 02a49c7b84c1ef8ee9b2eb343055d00bea02c338 Mon Sep 17 00:00:00 2001 From: Dylan Parker Date: Mon, 8 Feb 2021 21:07:59 -0600 Subject: [PATCH] add documenation for standalone gateway generation --- docs/docs/faq.md | 2 ++ docs/docs/mapping/grpc_api_configuration.md | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/docs/faq.md b/docs/docs/faq.md index 907ffb0943f..e670a9cabd1 100644 --- a/docs/docs/faq.md +++ b/docs/docs/faq.md @@ -10,6 +10,8 @@ nav_order: 7 The gRPC-Gateway follows the spec of [`google.api.HttpRule`](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto), so first check out the documentation if it is feasible in the spec. +For situations where annotating the proto file is not an option please reference the documentation on [gRPC API Configuration](https://grpc-ecosystem.github.io/grpc-gateway/docs/mapping/grpc_api_configuration/) + See also [a past discussion](https://groups.google.com/d/msg/grpc-io/Xqx80hG0D44/VNCDHjeE6pUJ) in the grpc-io mailing list. ## I want to support a certain style of HTTP request but the code generated by gRPC-Gateway does not. How can I support this style? diff --git a/docs/docs/mapping/grpc_api_configuration.md b/docs/docs/mapping/grpc_api_configuration.md index a6912f58b8c..6d69bbcc60f 100644 --- a/docs/docs/mapping/grpc_api_configuration.md +++ b/docs/docs/mapping/grpc_api_configuration.md @@ -11,8 +11,10 @@ In some situations annotating the proto file of service is not an option. For ex gRPC-Gateway supports 2 ways of dealing with these situations: -- [use the `generate_unbound_methods` option](#generate_unbound_methods) -- [provide an external configuration file](#using-an-external-configuration-file) (gRPC API Configuration) +- [gRPC API Configuration](#grpc-api-configuration) + - [`generate_unbound_methods`](#generate_unbound_methods) + - [Using an external configuration file](#using-an-external-configuration-file) + - [Usage of gRPC API Configuration YAML files](#usage-of-grpc-api-configuration-yaml-files) ## `generate_unbound_methods` @@ -100,6 +102,18 @@ It will generate a stub file with path `./gen/go/your/service/v1/your_service.pb This will generate a reverse proxy `gen/go/your/service/v1/your_service.pb.gw.go` that is identical to the one produced for the annotated proto. + In situations where you only need the reverse-proxy you can use the `standalone=true` option when generating the code. This will ensure the `types` used within `your_service.pb.gw.go` reference the external source appropriately. + + ``` + protoc -I . \ + --grpc-gateway_out ./gen/go \ + --grpc-gateway_opt logtostderr=true \ + --grpc-gateway_opt paths=source_relative \ + --grpc-gateway_opt standalone=true \ + --grpc-gateway_opt grpc_api_configuration=path/to/your_service.yaml \ + your/service/v1/your_service.proto + ``` + 6. Generate the optional your_service.swagger.json ```sh