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
Adds support to HTTP::Params.encode encode an arrays of values for a key. #7862
Adds support to HTTP::Params.encode encode an arrays of values for a key. #7862
Conversation
6947af1
to
6f1e7b8
Compare
How would slightly more complex structures look? data = {"key" => {"subkey" => ["a", "b"], "foo" => "bar", "baz" => [["c"], ["d"]]}
puts HTTP::Params.encode(data) # => ?? Or would just say that the default lib only supports very simple structures, and all complex matters need to be handled by individual frameworks? |
application/x-www-form-urlencoded doesn't define any such complex structures |
So the thing is, data = {"key" => ["a", "b"], "foo" => ["bar"]}
puts HTTP::Params.new(data) # => "key=a&key=b&foo=bar" so why introduce another slightly different and inconsistent approach? |
The implementation here looks good though, and actually doesn't add much complexity. |
@oprypin The problem on extending So instead of extending the From my point of view, be too strict on only accepting values as Array, is like passing the problem to the clients that will use |
6f1e7b8
to
d9a7319
Compare
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.
Some minor changes, but after that I'll approve and merge.
d9a7319
to
c6a2b1f
Compare
In practice, one problem here is that there is no standardized way to do it, so people have invented a whole bunch of ways. See https://swagger.io/docs/specification/describing-parameters/#query-parameters for a list of a bunch of different options. |
@asterite Applied the CR suggestions and pushed. The red on CI is something not related. |
c6a2b1f
to
6dcc9e6
Compare
What is this PR for?
This PR is for adding support to
HTTP::Params.encode
encode a key with an array of values. Like:This closes #7826