Skip to content

Commit 1fdec78

Browse files
authored
[GSoD] Refactoring the documentation files of gRPC-Gateway (#1851)
* fixed edit this page broken links * refactored md files * refactored documentation files * refactored documentation files * added requested changes * added requested changes
1 parent 283a152 commit 1fdec78

16 files changed

+108
-101
lines changed

ADOPTERS.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
This is a list of organizations that have spoken publicly about their adoption or
44
production users that have added themselves (in alphabetical order):
55

6-
* [Ad Hoc](http://adhocteam.us/) uses the gRPC-Gateway to serve millions of
7-
API requests per day.
8-
* [Chef](https://www.chef.io/) uses gRPC-Gateway to provide the user-facing
9-
API of [Chef Automate](https://automate.chef.io/). Furthermore, the generated
10-
OpenAPI data serves as the basis for its [API documentation](https://automate.chef.io/docs/api/).
11-
The code is Open Source, [see `github.com/chef/automate`](https://github.com/chef/automate).
12-
* [Scaleway](https://www.scaleway.com/en/) uses the gRPC-Gateway since 2018 to
13-
serve millions of API requests per day [1].
6+
- [Ad Hoc](http://adhocteam.us/) uses the gRPC-Gateway to serve millions of
7+
API requests per day.
8+
- [Chef](https://www.chef.io/) uses gRPC-Gateway to provide the user-facing
9+
API of [Chef Automate](https://automate.chef.io/). Furthermore, the generated
10+
OpenAPI data serves as the basis for its [API documentation](https://automate.chef.io/docs/api/).
11+
The code is Open Source, [see `github.com/chef/automate`](https://github.com/chef/automate).
12+
- [Scaleway](https://www.scaleway.com/en/) uses the gRPC-Gateway since 2018 to
13+
serve millions of API requests per day [1].
1414

1515
If you have adopted the gRPC-Gateway and would like to be included in this list,
1616
feel free to submit a PR.

CONTRIBUTING.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# How to contribute
22

3-
Thank you for your contribution to grpc-gateway.
3+
Thank you for your contribution to gRPC-Gateway.
44
Here's the recommended process of contribution.
55

66
1. `go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway`
@@ -16,13 +16,13 @@ Here's the recommended process of contribution.
1616
When you work on a larger contribution, it is also recommended that you get in touch
1717
with us through the issue tracker.
1818

19-
### Code reviews
19+
## Code reviews
2020

2121
All submissions, including submissions by project members, require review.
2222

23-
### I want to regenerate the files after making changes
23+
## I want to regenerate the files after making changes
2424

25-
#### Using Docker
25+
### Using Docker
2626

2727
It should be as simple as this (run from the root of the repository):
2828

@@ -42,7 +42,7 @@ docker run -itv $(pwd):/grpc-gateway -w /grpc-gateway --entrypoint /bin/bash --r
4242
You may need to authenticate with GitHub to pull `docker.pkg.github.com/grpc-ecosystem/grpc-gateway/build-env`.
4343
You can do this by following the steps on the [GitHub Package docs](https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-docker-for-use-with-github-packages#authenticating-to-github-packages).
4444

45-
#### Using Visual Studio Code dev containers
45+
### Using Visual Studio Code dev containers
4646

4747
This repo contains a `devcontainer.json` configuration that sets up the build environment in a container using
4848
[VS Code dev containers](https://code.visualstudio.com/docs/remote/containers). If you're using the dev container,
@@ -58,22 +58,22 @@ $ bazel run :gazelle -- update-repos -from_file=go.mod -to_macro=repositories.bz
5858
bazel run :buildifier
5959
```
6060

61-
Note that the above listed docker commands will not work in the dev container, since volume mounts from
62-
nested docker container are not possible.
61+
Note that the above-listed docker commands will not work in the dev container, since volume mounts from
62+
nested docker container is not possible.
6363

6464
If this has resulted in some file changes in the repo, please ensure you check those in with your merge request.
6565

66-
### Making a release
66+
## Making a release
6767

6868
To make a release, follow these steps:
6969

7070
1. Decide on a release version. The `gorelease` job can
71-
recommend whether the new release should be a patch or minor release.
72-
See [CircleCI](https://app.circleci.com/pipelines/github/grpc-ecosystem/grpc-gateway/126/workflows/255a8a04-de9c-46a9-a66b-f107d2b39439/jobs/6428)
73-
for an example.
71+
recommend whether the new release should be a patch or minor release.
72+
See [CircleCI](https://app.circleci.com/pipelines/github/grpc-ecosystem/grpc-gateway/126/workflows/255a8a04-de9c-46a9-a66b-f107d2b39439/jobs/6428)
73+
for an example.
7474
1. Generate a GitHub token with `repo` access.
7575
1. Create a new branch and edit the Makefile `changelog` job, settings
76-
the `future-release=` variable to the name of the version you plan to release
76+
the `future-release=` variable to the name of the version you plan to release
7777
1. Run `CHANGELOG_GITHUB_TOKEN=<yourtoken> make changelog`
7878
1. Commit the `Makefile` and `CHANGELOG.md` changes.
7979
1. Open a PR and check that everything looks right.

README.md

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
# grpc-gateway
1+
<div align="center">
2+
<h1>gRPC-Gateway</h1>
3+
<p>grpc-gateway
4+
gRPC to JSON proxy generator following the gRPC HTTP spec
5+
</p>
6+
<a href="https://circleci.com/gh/grpc-ecosystem/grpc-gateway"><img src="https://img.shields.io/circleci/build/github/grpc-ecosystem/grpc-gateway?color=379c9c&logo=circleci&logoColor=ffffff&style=flat-square"/></a>
7+
<a href="https://codecov.io/gh/grpc-ecosystem/grpc-gateway"><img src="https://img.shields.io/codecov/c/github/grpc-ecosystem/grpc-gateway?color=379c9c&logo=codecov&logoColor=ffffff&style=flat-square"/></a>
8+
<a href="https://app.slack.com/client/T029RQSE6/CBATURP1D"><img src="https://img.shields.io/badge/slack-grpc--gateway-379c9c?logo=slack&logoColor=ffffff&style=flat-square"/></a>
9+
<a href="https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt"><img src="https://img.shields.io/github/license/grpc-ecosystem/grpc-gateway?color=379c9c&style=flat-square"/></a>
10+
<a href="https://github.com/grpc-ecosystem/grpc-gateway/releases"><img src="https://img.shields.io/github/v/release/grpc-ecosystem/grpc-gateway?color=379c9c&logoColor=ffffff&style=flat-square"/></a>
11+
<a href="https://github.com/grpc-ecosystem/grpc-gateway/stargazers"><img src="https://img.shields.io/github/stars/grpc-ecosystem/grpc-gateway?color=379c9c&style=flat-square"/></a>
12+
</div>
213

3-
[![circleci](https://img.shields.io/circleci/build/github/grpc-ecosystem/grpc-gateway?color=379c9c&logo=circleci&logoColor=ffffff&style=flat-square)](https://circleci.com/gh/grpc-ecosystem/grpc-gateway)
4-
[![codecov](https://img.shields.io/codecov/c/github/grpc-ecosystem/grpc-gateway?color=379c9c&logo=codecov&logoColor=ffffff&style=flat-square)](https://codecov.io/gh/grpc-ecosystem/grpc-gateway)
5-
[![slack](https://img.shields.io/badge/slack-grpc--gateway-379c9c?logo=slack&logoColor=ffffff&style=flat-square)](https://app.slack.com/client/T029RQSE6/CBATURP1D)
6-
[![license](https://img.shields.io/github/license/grpc-ecosystem/grpc-gateway?color=379c9c&style=flat-square)](https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt)
7-
[![release](https://img.shields.io/github/v/release/grpc-ecosystem/grpc-gateway?color=379c9c&logoColor=ffffff&style=flat-square)](https://github.com/grpc-ecosystem/grpc-gateway/releases)
8-
[![stars](https://img.shields.io/github/stars/grpc-ecosystem/grpc-gateway?color=379c9c&style=flat-square)](https://github.com/grpc-ecosystem/grpc-gateway/stargazers)
14+
## About
915

10-
The grpc-gateway is a plugin of the Google protocol buffers compiler
16+
The gRPC-Gateway is a plugin of the Google protocol buffers compiler
1117
[protoc](https://github.com/protocolbuffers/protobuf).
1218
It reads protobuf service definitions and generates a reverse-proxy server which
1319
translates a RESTful HTTP API into gRPC. This server is generated according to the
@@ -23,13 +29,11 @@ This helps you provide your APIs in both gRPC and RESTful style at the same time
2329
## Testimonials
2430

2531
> We use the gRPC-Gateway to serve millions of API requests per day,
26-
> and have been since 2018, and through all of that,
32+
> and have been since 2018 and through all of that,
2733
> we have never had any issues with it.
2834
>
2935
> _- William Mill, [Ad Hoc](http://adhocteam.us/)_
3036
31-
## Check out our [documentation](https://grpc-ecosystem.github.io/grpc-gateway/)!
32-
3337
## Background
3438

3539
gRPC is great -- it generates API clients and server stubs in many programming
@@ -46,7 +50,7 @@ that's needed to generate a reverse-proxy with this library.
4650

4751
## Installation
4852

49-
The grpc-gateway requires a local installation of the Google protocol buffers
53+
The gRPC-Gateway requires a local installation of the Google protocol buffers
5054
compiler `protoc` v3.0.0 or above. Please install this via your local package
5155
manager or by downloading one of the releases from the official repository:
5256

@@ -151,7 +155,7 @@ Make sure that your `$GOBIN` is in your `$PATH`.
151155

152156
1. Using the default mapping
153157

154-
This requires no additional modification to the `.proto` file, but does require enabling a specific option when executing the plugin.
158+
This requires no additional modification to the `.proto` file but does require enabling a specific option when executing the plugin.
155159
The `generate_unbound_methods` should be enabled.
156160

157161
Here's what a `protoc` execution might look like with this option enabled:
@@ -213,7 +217,7 @@ Make sure that your `$GOBIN` is in your `$PATH`.
213217
```
214218

215219
3. External configuration
216-
If you do not want to (or cannot) modify the proto file for use with grpc-gateway you can
220+
If you do not want to (or cannot) modify the proto file for use with gRPC-Gateway you can
217221
alternatively use an external
218222
[gRPC Service Configuration](https://cloud.google.com/endpoints/docs/grpc/grpc-service-config) file.
219223
[Check our documentation](https://grpc-ecosystem.github.io/grpc-gateway/docs/grpcapiconfiguration.html)
@@ -292,15 +296,15 @@ Make sure that your `$GOBIN` is in your `$PATH`.
292296

293297
This GopherCon UK 2019 presentation from our maintainer
294298
[@JohanBrandhorst](https://github.com/johanbrandhorst) provides a good intro to
295-
using the grpc-gateway. It uses the following boilerplate repo as a base:
299+
using the gRPC-Gateway. It uses the following boilerplate repo as a base:
296300
https://github.com/johanbrandhorst/grpc-gateway-boilerplate.
297301

298302
[![gRPC-Gateway presentation](https://img.youtube.com/vi/Pq1paKC-fXk/0.jpg)](https://www.youtube.com/watch?v=Pq1paKC-fXk)
299303

300304
## Parameters and flags
301305

302-
During code generation with `protoc`, flags to grpc-gateway tools must be passed
303-
through protoc using one of 2 patterns:
306+
During code generation with `protoc`, flags to gRPC-Gateway tools must be passed
307+
through `protoc` using one of 2 patterns:
304308

305309
- as part of the `--<tool_suffix>_out` `protoc` parameter: `--<tool_suffix>_out=<flags>:<path>`
306310

@@ -325,12 +329,12 @@ through protoc using one of 2 patterns:
325329
Golang import paths. They are compatible with
326330
[the parameters with the same names in `protoc-gen-go`](https://github.com/golang/protobuf#parameters).
327331

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

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

336340
Similarly, `protoc-gen-openapiv2` supports command-line flags to control OpenAPI
@@ -342,9 +346,9 @@ files with options from
342346
[a_bit_of_everything.proto](examples/internal/proto/examplepb/a_bit_of_everything.proto)
343347
for examples.
344348

345-
## More Examples
349+
## More examples
346350

347-
More examples are available under `examples` directory.
351+
More examples are available under the `examples` directory.
348352

349353
- `proto/examplepb/echo_service.proto`, `proto/examplepb/a_bit_of_everything.proto`, `proto/examplepb/unannotated_echo_service.proto`: service definition
350354
- `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
@@ -365,7 +369,7 @@ gRPC-gateway, and a gRPC server, see
365369
- Generating JSON API handlers.
366370
- Method parameters in the request body.
367371
- Method parameters in the request path.
368-
- Method parameters in query string.
372+
- Method parameters in the query string.
369373
- Enum fields in the path parameter (including repeated enum fields).
370374
- Mapping streaming APIs to newline-delimited JSON streams.
371375
- Mapping HTTP headers with `Grpc-Metadata-` prefix to gRPC metadata (prefixed with `grpcgateway-`)
@@ -381,14 +385,14 @@ gRPC-gateway, and a gRPC server, see
381385

382386
### No plan to support
383387

384-
But patch is welcome.
388+
But patches are welcome.
385389

386390
- Method parameters in HTTP headers.
387391
- Handling trailer metadata.
388392
- Encoding request/response body in XML.
389393
- True bi-directional streaming.
390394

391-
# Mapping gRPC to HTTP
395+
## Mapping gRPC to HTTP
392396

393397
- [How gRPC error codes map to HTTP status codes in the response](https://github.com/grpc-ecosystem/grpc-gateway/blob/master/runtime/errors.go#L15).
394398
- HTTP request source IP is added as `X-Forwarded-For` gRPC request header.
@@ -404,11 +408,11 @@ But patch is welcome.
404408
[jsonpb](https://pkg.go.dev/github.com/golang/protobuf/jsonpb) with
405409
`OrigName: true`.
406410

407-
# Contribution
411+
## Contribution
408412

409413
See [CONTRIBUTING.md](http://github.com/grpc-ecosystem/grpc-gateway/blob/master/CONTRIBUTING.md).
410414

411-
# License
415+
## License
412416

413-
grpc-gateway is licensed under the BSD 3-Clause License.
417+
gRPC-Gateway is licensed under the BSD 3-Clause License.
414418
See [LICENSE.txt](https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt) for more details.

docs/_config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ gh_edit_link: true # show or hide edit this page link
7777
gh_edit_link_text: "Edit this page on GitHub"
7878
gh_edit_repository: "https://github.com/grpc-ecosystem/grpc-gateway" # the github URL for your repo
7979
gh_edit_branch: "master" # the branch that your docs is served from
80-
# gh_edit_source: docs # the source that your files originate from
80+
gh_edit_source: docs # the source that your files originate from
8181
gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into the editor immediately
8282

8383
# Color scheme currently only supports "dark", "light"/nil (default), or a custom scheme that you define
8484
color_scheme: nil
8585

8686
# Disqus Comments
8787
# disqus:
88-
# Leave shortname blank to disable comments site-wide.
89-
# Enable comments for any post by adding `comments: true` to that post's YAML Front Matter.
90-
# shortname:
88+
# Leave shortname blank to disable comments site-wide.
89+
# Enable comments for any post by adding `comments: true` to that post's YAML Front Matter.
90+
# shortname:
9191

9292
# Google Analytics Tracking
9393
# e.g, UA-1234567-89

docs/docs/contributing/contributing.md

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
layout: default
3+
title: Getting Started
4+
parent: Contributing
5+
---
6+
7+
# How to contribute
8+
9+
See CONTRIBUTING in [CONTRIBUTING.md](https://github.com/grpc-ecosystem/grpc-gateway/blob/master/CONTRIBUTING.md).

docs/docs/tutorials/adding_annotations.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
layout: default
3-
title: Adding the grpc-gateway annotations to an existing protobuf file
3+
title: Adding gRPC-Gateway annotations to an existing proto file
4+
nav_order: 4
45
parent: Tutorials
5-
nav_order: 5
66
---
77

8-
# Adding the grpc-gateway annotations to an existing protobuf file
8+
# Adding gRPC-Gateway annotations to an existing proto file
99

10-
Now that we've got a working Go gRPC server, we need to add the grpc-gateway annotations.
10+
Now that we've got a working Go gRPC server, we need to add the gRPC-Gateway annotations.
1111

1212
The annotations define how gRPC services map to the JSON request and response. When using protocol buffers, each RPC must define the HTTP method and path using the `google.api.http` annotation.
1313

14-
So we will need to add the `google/api/http.proto` import to the proto file. We also need to add the HTTP->gRPC mapping we want. In this case, we're mapping `POST /v1/example/echo` to our `SayHello` rpc.
14+
So we will need to add the `google/api/http.proto` import to the proto file. We also need to add the HTTP->gRPC mapping we want. In this case, we're mapping `POST /v1/example/echo` to our `SayHello` RPC.
1515

16-
```proto
16+
```protobuf
1717
syntax = "proto3";
1818
1919
package helloworld;
@@ -44,11 +44,11 @@ message HelloReply {
4444

4545
See [a_bit_of_everything.proto](https://github.com/grpc-ecosystem/grpc-gateway/blob/master/examples/internal/proto/examplepb/a_bit_of_everything.proto) for examples of more annotations you can add to customize gateway behavior.
4646

47-
## Generating the grpc-gateway stubs
47+
## Generating the gRPC-Gateway stubs
4848

49-
Now that we've got the grpc-gateway annotations added to the proto file, we need to use the grpc-gateway generator to generate the stubs.
49+
Now that we've got the gRPC-Gateway annotations added to the proto file, we need to use the gRPC-Gateway generator to generate the stubs.
5050

51-
Before we can do that, we need to copy some dependencies into our protofile structure. Copy the `third_party/googleapis` folder from the grpc-gateway repository to your local protofile structure. It should look like this afterwards:
51+
Before we can do that, we need to copy some dependencies into our proto file structure. Copy the `third_party/googleapis` folder from the gRPC-Gateway repository to your local proto file structure. It should look like this afterwards:
5252

5353
```
5454
proto
@@ -62,9 +62,9 @@ proto
6262

6363
### Using buf
6464

65-
We'll need to add the grpc-gateway generator to the generation configuration:
65+
We'll need to add the gRPC-Gateway generator to the generation configuration:
6666

67-
```yml
67+
```yaml
6868
version: v1beta1
6969
plugins:
7070
- name: go
@@ -86,9 +86,9 @@ $ buf generate
8686

8787
It should produce a `*.gw.pb.go` file.
8888

89-
### Using protoc
89+
### Using `protoc`
9090

91-
Now we need to add the grpc-gateway generator to the protoc invocation:
91+
Now we need to add the gRPC-Gateway generator to the `protoc` invocation:
9292

9393
```sh
9494
$ protoc -I ./proto \
@@ -100,7 +100,7 @@ $ protoc -I ./proto \
100100

101101
This should generate a `*.gw.pb.go` file.
102102

103-
We also need to add and serve the gRPC-gateway mux in our `main.go` file.
103+
We also need to add and serve the gRPC-Gateway mux in our `main.go` file.
104104

105105
```go
106106
package main

docs/docs/tutorials/creating_main.go.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
layout: default
33
title: Creating main.go
4+
nav_order: 3
45
parent: Tutorials
5-
nav_order: 4
66
---
77

88
# Creating main.go

docs/docs/tutorials/generating_stubs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
layout: default
33
title: Generating stubs
44
parent: Tutorials
5-
nav_order: 3
5+
nav_order: 2
66
has_children: true
77
---
88

0 commit comments

Comments
 (0)