Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documenation for standalone gateway generation #1955

Merged
merged 1 commit into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
18 changes: 16 additions & 2 deletions docs/docs/mapping/grpc_api_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down Expand Up @@ -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
Expand Down