-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
This option will replace our custom option
Add an integration test
Conflicts: examples/server/main.go
Hi @yugui, Thank you for your excellent work on this! I've been testing out an earlier version of this branch. I'll be updating to the latest and giving it a try next. |
@@ -70,7 +70,7 @@ Make sure that your `$GOPATH/bin` is in your `$PATH`. | |||
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 comment
The 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:
post: "/v1/example/echo"
body: "*"
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.
Done.
|
||
var _ codes.Code | ||
var _ io.Reader | ||
var _ = runtime.String |
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.
You may want to insert var _ = json.Marshal
or similar here, otherwise it will potentially generate Go code that does not compile:
....pb.gw.go:13: imported and not used: "encoding/json"
That will only happen if none of the services have a body or parameters, hence json package goes unused.
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.
Done.
This is because all methods will share the same set of decoders. https://groups.google.com/d/msg/grpc-io/Xqx80hG0D44/1gwmwBcnNScJ Tentatively json.Decoder is hard-coded in the code template. We are also going to support application/x-www-form-urlencoded and eventually it will get pluggable by commandline flag.
+import "github.com/gengo/grpc-gateway/options/options.proto"; | ||
|
||
+ | ||
+import "github.com/gengo/grpc-gateway/third_party/googleapis/google/api/annnotations.proto"; |
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 annotations
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.
done. thx
Replace our own custom option with the one defined by Google
Is the implementation of query parameters complete? |
By the way, thank you very much for your excellent work on this @yugui, it is very helpful and much appreciated! |
change amount type to int64.
Background
The new option brings:
Overview