-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
feature-requestA feature requestA feature request
Description
Describe the feature you'd like
I want yew::format::urlencoded::UrlEncoded(T) format request to application/x-www-form-urlencoded and parse response.
Is your feature request related to a problem? Please describe. (Optional)
I don't know why this feature is not implemented.
Describe alternatives you've considered (Optional)
For my app, I implemented this with serde_urlencoded.
pub struct UrlEncoded<T>(T);
impl<'a, T> Into<Result<String, anyhow::Error>> for UrlEncoded<&'a T>
where
T: serde::Serialize
{
fn into(self) -> Result<String, anyhow::Error> { Ok(serde_urlencoded::to_string(self.0)?) }
}
#[derive(Debug, PartialEq, Clone, Serialize)]
pub struct Request {
ident: String,
password: String
}
#[test]
fn encode_request() {
let req = Request {
ident: "foo@example.com".into(),
password: "0000".into()
};
let rb: Result<String, anyhow::Error> = UrlEncoded(&req).into();
let b = rb.expect("failure serialize");
assert_eq!("ident=foo%40example.com&password=0000", b);
}
Additional context (Optional)
Questionnaire
- I'm interested in implementing this myself but don't know where to start
- I would like to add this feature
- I don't have time to add this right now, but maybe later
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature-requestA feature requestA feature request