-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Replace our own custom option with the one defined by Google #12
Changes from 26 commits
ea9f6ac
9bf40a9
d08615b
ae7afe3
3daa1df
a8d4491
e407fb1
34560be
2b41609
0ad57f7
d8bcb11
f709571
af1c482
5783729
85ef5cf
415c655
9b048b1
8cfb28f
b807c97
d8399af
a584b49
adba95a
8308b8f
169d51e
17fee9f
593bfcc
0691d05
9b03271
334e625
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,17 +60,17 @@ Make sure that your `$GOPATH/bin` is in your `$PATH`. | |
```diff | ||
syntax = "proto3"; | ||
package example; | ||
+import "github.com/gengo/grpc-gateway/options/options.proto"; | ||
+ | ||
+import "github.com/gengo/grpc-gateway/third_party/googleapis/google/api/annnotations.proto"; | ||
+ | ||
message StringMessage { | ||
string value = 1; | ||
} | ||
|
||
service YourService { | ||
- rpc Echo(StringMessage) returns (StringMessage) {} | ||
+ rpc Echo(StringMessage) returns (StringMessage) { | ||
+ option (gengo.grpc.gateway.ApiMethodOptions.api_options) = { | ||
+ option (google.api.http) = { | ||
+ path: "/v1/example/echo" | ||
+ method: "POST" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this part of the example need to be updated to match the Google api definitions? If I understand correctly, it should now be:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
+ }; | ||
|
@@ -86,8 +86,21 @@ Make sure that your `$GOPATH/bin` is in your `$PATH`. | |
``` | ||
|
||
It will generate a stub file `path/to/your_service.pb.go`. | ||
Now you can implement your service on top of the stub. | ||
4. Generate reverse-proxy | ||
4. Implement your service in gRPC as usual | ||
1. (Optional) Generate gRPC stub in the language you want. | ||
|
||
e.g. | ||
```sh | ||
protoc -I/usr/local/include -I. -I$GOPATH/src --ruby_out=. \ | ||
path/to/your/service_proto | ||
|
||
protoc -I/usr/local/include -I. -I$GOPATH/src \ | ||
--plugin=protoc-gen-grpc-ruby=grpc_ruby_plugin \ | ||
--grpc-ruby_out=. \ | ||
path/to/your/service.proto | ||
``` | ||
2. Implement your service | ||
5. Generate reverse-proxy | ||
|
||
```sh | ||
protoc -I/usr/local/include -I. -I$GOPATH/src \ | ||
|
@@ -96,7 +109,7 @@ Make sure that your `$GOPATH/bin` is in your `$PATH`. | |
``` | ||
|
||
It will generate a reverse proxy `path/to/your_service.pb.gw.go`. | ||
5. Write an entrypoint | ||
6. Write an entrypoint | ||
|
||
Now you need to write an entrypoint of the proxy server. | ||
```go | ||
|
@@ -106,8 +119,8 @@ Make sure that your `$GOPATH/bin` is in your `$PATH`. | |
"net/http" | ||
|
||
"github.com/golang/glog" | ||
"github.com/zenazn/goji/web" | ||
"golang.org/x/net/context" | ||
"github.com/gengo/grpc-gateway/runtime" | ||
|
||
gw "path/to/your_service_package" | ||
) | ||
|
@@ -121,7 +134,7 @@ Make sure that your `$GOPATH/bin` is in your `$PATH`. | |
ctx, cancel := context.WithCancel(ctx) | ||
defer cancel() | ||
|
||
mux := web.New() | ||
mux := runtime.NewServeMux() | ||
err := gw.RegisterYourServiceHandlerFromEndpoint(ctx, mux, *echoEndpoint) | ||
if err != nil { | ||
return err | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One too many
n
's in annotationsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. thx