Skip to content

Commit 3c4b5a0

Browse files
authored
add documenation for standalone gateway generation (#1955)
1 parent b55d462 commit 3c4b5a0

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

docs/docs/faq.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ nav_order: 7
1010

1111
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.
1212

13+
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/)
14+
1315
See also [a past discussion](https://groups.google.com/d/msg/grpc-io/Xqx80hG0D44/VNCDHjeE6pUJ) in the grpc-io mailing list.
1416

1517
## 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?

docs/docs/mapping/grpc_api_configuration.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ In some situations annotating the proto file of service is not an option. For ex
1111

1212
gRPC-Gateway supports 2 ways of dealing with these situations:
1313

14-
- [use the `generate_unbound_methods` option](#generate_unbound_methods)
15-
- [provide an external configuration file](#using-an-external-configuration-file) (gRPC API Configuration)
14+
- [gRPC API Configuration](#grpc-api-configuration)
15+
- [`generate_unbound_methods`](#generate_unbound_methods)
16+
- [Using an external configuration file](#using-an-external-configuration-file)
17+
- [Usage of gRPC API Configuration YAML files](#usage-of-grpc-api-configuration-yaml-files)
1618

1719
## `generate_unbound_methods`
1820

@@ -100,6 +102,18 @@ It will generate a stub file with path `./gen/go/your/service/v1/your_service.pb
100102

101103
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.
102104

105+
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.
106+
107+
```
108+
protoc -I . \
109+
--grpc-gateway_out ./gen/go \
110+
--grpc-gateway_opt logtostderr=true \
111+
--grpc-gateway_opt paths=source_relative \
112+
--grpc-gateway_opt standalone=true \
113+
--grpc-gateway_opt grpc_api_configuration=path/to/your_service.yaml \
114+
your/service/v1/your_service.proto
115+
```
116+
103117
6. Generate the optional your_service.swagger.json
104118

105119
```sh

0 commit comments

Comments
 (0)