-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Allow bind with a map[string]string #2484
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2484 +/- ##
==========================================
+ Coverage 98.46% 98.48% +0.01%
==========================================
Files 41 41
Lines 1952 1974 +22
==========================================
+ Hits 1922 1944 +22
Misses 17 17
Partials 13 13
Continue to review full report at Codecov.
|
Hi is there any update on this? @thinkerou or someone else? |
Ping on this 😄 @thinkerou |
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.
lgtm
It's always been possible to bind using an object of type
map[string]string
. For example:If the request body was formatted as JSON (or YAML), this worked fine. You'd get a dictionary with key-values. For example, with input:
You'd get in the object:
obj["foo"] = "bar"
obj["hello"] = "world"
However, this did not work if the request's body was form-encoded (
application/x-www-form-urlencoded
ormultipart/form-data
).This PR adds support for passing a pointer to
map[string]string
toBind
that works with: Forms (POST Forms, Multipart forms), JSON, YAML. It also works with query strings. (However, it does NOT work with XML, because the XML parser doesn't allow that).Why is this useful? Sometimes, there are situations in which I'm expecting a key-value dictionary, but I do not know what keys I'll receive.
This PR includes tests.