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

Replace our own custom option with the one defined by Google #12

Merged
merged 29 commits into from
May 9, 2015

Conversation

yugui
Copy link
Member

@yugui yugui commented May 4, 2015

Background

The new option brings:

  • More expressiveness of method mapping
  • Compatibility to api definitions released by Google

Overview

  • Import the definition files of the custom option from github.com/google/googleapis.
  • Deprecate our own custom option
  • Extract the parse process of CodeGeneratorRequest from code template execution
  • Add a parser of path pattern rule defined in googleapis
  • Add a stack machine which executes the parsed rule
  • Add a compiler which compiles the parsed rule into opcodes in the stack machine
  • Redesign the code template on top of this new stuff
  • Update examples

@dmitshur
Copy link
Contributor

dmitshur commented May 4, 2015

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"
Copy link
Contributor

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: "*"

Copy link
Member Author

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
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

yugui added 2 commits May 5, 2015 12:29
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";

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. thx

yugui added a commit that referenced this pull request May 9, 2015
Replace our own custom option with the one defined by Google
@yugui yugui merged commit 4747d51 into master May 9, 2015
@dmitshur
Copy link
Contributor

dmitshur commented May 9, 2015

Is the implementation of query parameters complete?

@dmitshur
Copy link
Contributor

dmitshur commented May 9, 2015

By the way, thank you very much for your excellent work on this @yugui, it is very helpful and much appreciated!

@yugui
Copy link
Member Author

yugui commented May 11, 2015

@shurcooL Not yet. But it was enough to replace the old implementation.
I am working on query parameters and other updates from Wolfgang in another branch #14.

@yugui yugui deleted the feature/google-http-rule branch August 31, 2015 00:17
ithinker1991 referenced this pull request in tronprotocol/grpc-gateway Apr 26, 2018
Evgeniy-L pushed a commit to Evgeniy-L/grpc-gateway that referenced this pull request Nov 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants