--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/82b1372f-0f2f-41f8-9c67-5e3ae21f3165%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAOWnRi8o_iR7X36PueKgX9HdfXRTP00f%2B-CY1d6c27YKaT2k5Q%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/2f1ae4e4-8db0-4077-977e-28efccea510b%40googlegroups.com.
grpc-gateway indeed is very cool. As Louis mentioned earlier, we also have similar mechanism used internally at Google to convert between REST and gRPC.We have now put those annotations/spec in github at https://github.com/google/googleapis/tree/master/google/api It would be great if we can consolidate anduse same mechanism for consistency in different projects that need gRPC-REST conversion. Can we update grpc-gateway to use same annotations?
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CALLfn8C1vJf4%3DogqicxZHPE8ZR%3DmW385o8DCJ17O%2Bzjp%3DL5%2BYQ%40mail.gmail.com.
1. The `body` field specifies either `*` or a field path, or isomitted. If omitted, it assumes there is no HTTP body.
// Verb = ":" LITERAL ;
// Additional HTTP bindings for the selector. Nested bindings must not// specify a selector and must not contain additional bindings.repeated HttpRule additional_bindings = 11;
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CALLfn8C1vJf4%3DogqicxZHPE8ZR%3DmW385o8DCJ17O%2Bzjp%3DL5%2BYQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAB%3Drkjz7%3DEBtvp6_OfjAjE%3DPh%2Bti0_ipjHM181wnoEvHxNG%2BAQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CADQ0XY2yt4dgRUS%3D2fq4XU%3D63-AwmZUTr8CoT_GvW5A150U7SQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CALLfn8BbR%2BLjP0c0CHtMjMjujTcNgUkpFwOxLBfx8OAfo9fY8w%40mail.gmail.com.
Hi Jayant,I have several questions about the spec. Let me clarify.1. The `body` field specifies either `*` or a field path, or isomitted. If omitted, it assumes there is no HTTP body.I guess "a field path" is a path to a field in the message or one in a nested message.
What happens if there is a repeated field on the path?Does the path select all items in the repeated field or only the first item?
// Verb = ":" LITERAL ;How the Verb part of the template is to be used?
// Additional HTTP bindings for the selector. Nested bindings must not// specify a selector and must not contain additional bindings.repeated HttpRule additional_bindings = 11;What is "selector" in this context?
Would you mind showing me an example usage of additional_bindings?
rpc GetObject(GetObjectRequest) returns (Object) {option (google.api.http) = {get: "/v1/projects/{project_id}/objects/{object_id}"additional_bindings {get: "/v1/objects/{object_id}"}};}
UpdateI have just implemented a new code generator for the new custom option.
https://github.com/gengo/grpc-gateway/pull/12
The branch will be merged into master as soon as we complete the code review.
QuestionAlso I have another question. I'd like to add some fields in the custom option to support the following things.How can I discuss this change in google/api/http.proto? Can I just send a pull request to github.com/google/googleapis?
The features I want to add are:
- Content-Type of request/response body -- I'd like to support application/x-www-form-urlencoded
- optional request parameters (fields) in query strings.
On Monday, May 4, 2015 at 4:15:41 AM UTC-7, Yugui Sonoda wrote:
The features I want to add are:
- Content-Type of request/response body -- I'd like to support application/x-www-form-urlencoded
This would not need an extension of the custom option. Rather, I think this should be always supported (and in our internal implementation, we do this.) I think we should move this paragraph from out internal doc into the http.proto:
message RequestBody {message Inner {repeated string value = 1;}repeated Inner nest = 1;}
nest[0].value[0]=foo&nest[0].value[1]=bar&nest[1].value[0]=baz&nest[2].value[0]=qux
- optional request parameters (fields) in query strings.
If I understand correctly, this is already covered. Every field not mapped via URL path or body automatically becomes an HTTP parameter.
option (google.api.http) = {
post: "upload/storage/v1/b/{bucket}/o"query_string: "upload_type"query_string: "content_encoding"query_string: ...body: "*"};
// The name of the request field whose value is mapped to the HTTP body, or
// `*` for mapping all fields not captured by the path pattern to the HTTP
// body. NOTE: the referred field must not be a repeated field.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/66aa1ca2-0038-4eac-9c6b-e3f4fb4efc92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wolfgang, thank you for your answers.For the questions in the first mail, they are now clear for me.Let me ask more questions about your reply to application/x-www-form-urlencoded and query sting parameters.On Tue, May 5, 2015 at 2:11 AM Wolfgang Grieskamp <w...@google.com> wrote:
On Monday, May 4, 2015 at 4:15:41 AM UTC-7, Yugui Sonoda wrote:The features I want to add are:
- Content-Type of request/response body -- I'd like to support application/x-www-form-urlencoded
This would not need an extension of the custom option. Rather, I think this should be always supported (and in our internal implementation, we do this.) I think we should move this paragraph from out internal doc into the http.proto:Ah, that makes sense. But it brings another question.Originally I was thinking of supporting x-www-form-urlencoded only if the request type was flat and non-repeated.But if we always support x-www-form-urlencoded, how do you represent repeated message fields? For example, what would the urlencoded form of RequestBody message below look like?message RequestBody {message Inner {repeated string value = 1;}repeated Inner nest = 1;}One possible solution is to extend application/x-www-form-urlencoded as Ruby on Rails or PHP does. In this extension, the serialization of RequestBody would look like below. But I'd like to keep it consistent to the implementation in Google.nest[0].value[0]=foo&nest[0].value[1]=bar&nest[1].value[0]=baz&nest[2].value[0]=qux
Also for query strings,
- optional request parameters (fields) in query strings.
If I understand correctly, this is already covered. Every field not mapped via URL path or body automatically becomes an HTTP parameter.I sounds like that query parameters are a kind of "catch-all" things. But how do you represent an API like the object insert API of Google Cloud Storage with that approach?I thought it would be something like:option (google.api.http) = {post: "upload/storage/v1/b/{bucket}/o"query_string: "upload_type"query_string: "content_encoding"query_string: ...body: "*"};
Another example is the Disk insert API in Google Compute Engine.// The name of the request field whose value is mapped to the HTTP body, or
// `*` for mapping all fields not captured by the path pattern to the HTTP
// body. NOTE: the referred field must not be a repeated field.IIUC, what "body" field in google.api.http option can do is only to (1) map a single field to request body; or (2) catch all.So it cannot coexist with "catch-all" query parameters. Thus I need to explicitly declare a list of query parameters so that they are always provided in query strings but not in request body.
On Mon, May 4, 2015 at 7:15 PM, Yugui <yu...@yugui.jp> wrote:Wolfgang, thank you for your answers.For the questions in the first mail, they are now clear for me.Let me ask more questions about your reply to application/x-www-form-urlencoded and query sting parameters.On Tue, May 5, 2015 at 2:11 AM Wolfgang Grieskamp <w...@google.com> wrote:
On Monday, May 4, 2015 at 4:15:41 AM UTC-7, Yugui Sonoda wrote:The features I want to add are:
- Content-Type of request/response body -- I'd like to support application/x-www-form-urlencoded
This would not need an extension of the custom option. Rather, I think this should be always supported (and in our internal implementation, we do this.) I think we should move this paragraph from out internal doc into the http.proto:Ah, that makes sense. But it brings another question.Originally I was thinking of supporting x-www-form-urlencoded only if the request type was flat and non-repeated.But if we always support x-www-form-urlencoded, how do you represent repeated message fields? For example, what would the urlencoded form of RequestBody message below look like?message RequestBody {message Inner {repeated string value = 1;}repeated Inner nest = 1;}One possible solution is to extend application/x-www-form-urlencoded as Ruby on Rails or PHP does. In this extension, the serialization of RequestBody would look like below. But I'd like to keep it consistent to the implementation in Google.nest[0].value[0]=foo&nest[0].value[1]=bar&nest[1].value[0]=baz&nest[2].value[0]=quxI should have been clearer. The idea is that urlencoded would only be used for methods declared as GET to bypass URL length restrictions. So only what is already a URL would appear here, and in URLs we only allow repeated fields of primitive types.So this restriction helps us here ;-)
BTW, the restriction has the following motivation. Many existing REST API frameworks don't support complex value bindings in the URLs (e.g. Swagger). We felt it's better to not offer this feature to encourage API design with interoperability in mind. Its clear there are technical ways to do this (my preferred one would probably be oriented towards jQuery).
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAFuU7PacS2LGWJjFGjamAdnVGrrbNSV25GoABGjaOkrjwvo_Kg%40mail.gmail.com.
But I'd like to keep urlencoded parameters as simple as you explained. Urlencoding of Body is supported only if body parameters are simple.It won't break compatibility to Google's spec.
Let me ask some more questions.
- How the request path will look like when its path parameters are placed in the request body to bypass the length restriction?
- How does it look like in the request path when repeated fields of primitive types are placed in path parameters?
Ah, the second question might be wrong.When you said "So only what is already a URL would appear here, and in URLs we only allow repeated fields of primitive types.", I thought the repeated fields were coming from path of the URL.But did you mean the repeated fields were coming from query string?
Let me confirm. Is the following understanding correct?
- Request Body (JSON)
- fields of aggregate types are not allowed
- repeated fields are allowed
- Request Path
- fields of aggregate types are not allowed
- nested fields (fields in a message field) are allowed if primitive
- repeated fields are not allowed
- Query string
- fields of aggregate types are not allowed
- nested fields are allowed if primitive?
- repeated fields are allowed if primitive
- I still wonder if it would be better to explicitly declare that the POST/PUT method supports application/x-www-form-urlencoded in a field like
repeated string body_encoding = n;
of the custom option.
If we don't have such a option field, a method can silently lose support of application/x-www-form-urlencoded when an user adds a repeated message field to the request message type.
On the other hand, protoc-gen-grpc-gateway can display an error if the method has both repeated message field and "body_encoding = 'application/x-www-form-urlencoded'".
What do you think?
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAFuU7PYdeuO8%3DAmZO52gtAuU3Ust_fWMkYEmrnDiBWCnSie6yQ%40mail.gmail.com.