-
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
support custom HTTP Query URI names to make a nicer UX for deeply nested messages #3290
Comments
in protobuf we can already configure json marshaling names via the `json` tag. This PR adds a similar capability to customize URL query names via a `query` tag to either: * use a short alias for HTTP GET URL query arguments * use a blank name to avoid a prefix of nested objects e.g. if you use a common `Filter` object in `SomeRequest ` you can omit the `filter.` prefix on the query URL values for properties in the filter message Fixes grpc-ecosystem#3290
in protobuf we can already configure json marshaling names via the `json` tag. This PR adds a similar capability to customize URL query names via a `query` tag to either: * use a short alias for HTTP GET URL query arguments * use a blank name to avoid a prefix of nested objects e.g. if you use a common `Filter` object in `SomeRequest ` you can omit the `filter.` prefix on the query URL values for properties in the filter message Fixes grpc-ecosystem#3290
I've submitted a PR but I've not yet figured out the magic permutations to get me past the CLA checker... |
Hi James, thanks for the issue. I'm going to be frank, I don't think this functionality belongs in this project. However, that's not to say that your PR isn't addressing a real problem that users have. I'm thinking this could make a cool example of how you can customize the grpc-gateway's query parameter parser outside of the default behavior. As far as I can tell, there's nothing in your PR that can't be covered with a custom QueryParameterParser and some post-processing of the generated files (as you're already doing with protoc-gen-gotag). What I'd like to maybe get out of this would be a little section of our docs that could show this in action, rather than deeply integrated with the gateway itself. What do you think? |
in protobuf we can already configure json marshaling names via the `json` tag. This PR adds a similar capability to customize URL query names via a `query` tag to either: * use a short alias for HTTP GET URL query arguments * use a blank name to avoid a prefix of nested objects e.g. if you use a common `Filter` object in `SomeRequest ` you can omit the `filter.` prefix on the query URL values for properties in the filter message Fixes grpc-ecosystem#3290
in protobuf we can already configure json marshaling names via the `json` tag. This PR adds a similar capability to customize URL query names via a `query` tag to either: * use a short alias for HTTP GET URL query arguments * use a blank name to avoid a prefix of nested objects e.g. if you use a common `Filter` object in `SomeRequest ` you can omit the `filter.` prefix on the query URL values for properties in the filter message Fixes grpc-ecosystem#3290
in protobuf we can already configure json marshaling names via the `json` tag. This PR adds a similar capability to customize URL query names via a `query` tag to either: * use a short alias for HTTP GET URL query arguments * use a blank name to avoid a prefix of nested objects e.g. if you use a common `Filter` object in `SomeRequest ` you can omit the `filter.` prefix on the query URL values for properties in the filter message Fixes grpc-ecosystem#3290
@johanbrandhorst I'd missed that the The trickier thing is I was going to then supply another PR to modify the I'll look into its relatively easy to add some kind of plugin there too maybe... |
@jstrachan I'm interested in this also, I have a legacy API that I would like to map to new GRPC endpoints, and not being able to customize how query parameters are handled will prevent a lot of things of being converted. Did you find any good solution? |
馃殌 Feature
protobuf
prefers composition of messages instead of inheritance. Its very common for HTTP GET requests to take common nested filter messages which then leads to a verbose URI.e.g. if you use a common
Filter
object (for search text, sort, pagination etc) inSomeRequest
then your HTTP GET URI would be something like?filter.query=foo&filter.sort=ASC&filter.page=1
in protobuf we can already configure json marshalling names via the
json
tag. It would be nice to be able to support aquery
tag for providing a custom HTTP GET query URI parameter name used when exposing the service over HTTP GET.We can then leave the POST / proto / JSON encoding alone but have nicer GET URIs if required. e.g.
?q=foo&sort=ASC&page=1
I've an experimental PR on the way soon that implements this to see what folks think...
The text was updated successfully, but these errors were encountered: