Add with_form method for URL-encoded form data#470
Add with_form method for URL-encoded form data#470crodas wants to merge 2 commits intorust-bitcoin:masterfrom
with_form method for URL-encoded form data#470Conversation
Add support for sending application/x-www-form-urlencoded form data in HTTP requests via a new `with_form()` method on `Request`. - Add `serde_urlencoded` dependency for form serialization - Add `SerdeUrlencodeError` variant to handle encoding failures - Add unit tests for form encoding behavior - Add integration tests for form submission
f341a66 to
a253ca1
Compare
Add instead a minimal equivalent that uses serde to serialize any struct with url encoding
| } | ||
|
|
||
| /// Percent-encode a string for use in URL form data. | ||
| fn percent_encode(s: &str) -> String { |
There was a problem hiding this comment.
Not the biggest fan of adding all this serialization boilerplate here. At the very least we should DRY this up after #467 lands, as we have at least all the the percent encoding stuff, etc there.
There was a problem hiding this comment.
The alternative would be to receive something that can be converted into Vec<(&str, &str)>, and in that case, it would be useful enough, but I think, since this would be optional, using some serde magic is acceptable, but I lack context to make that judgment call.
There was a problem hiding this comment.
Offering only the serde-based option kinda sucks (now you have to use serde just to percent-encode a few fields? bleh) but if y'all have a desire for a serde-based option I don't see a reason that we can't offer it as well.
Indeed, though, we should figure out how to sequence this with #467 since there's overlap.
Add support for sending application/x-www-form-urlencoded form data in HTTP requests via a new
with_form()method onRequest.serde_urlencodeddependency for form serializationSerdeUrlencodeErrorvariant to handle encoding failures