Skip to content

Commit

Permalink
Merge pull request #180 from secretfader/serde_urlencoded
Browse files Browse the repository at this point in the history
Migrate to serde_urlencoded, and away from serde_qs
  • Loading branch information
aturon authored Apr 24, 2019
2 parents 4263895 + 0dedfc0 commit d76a6d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ route-recognizer = "0.1.12"
serde = "1.0.90"
serde_derive = "1.0.90"
serde_json = "1.0.39"
serde_qs = "0.4.5"
slog = "2.4.1"
slog-async = "2.3.0"
slog-term = "2.4.0"
Expand Down
6 changes: 4 additions & 2 deletions src/forms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<AppData: Send + Sync + 'static> ExtractForms for Context<AppData> {
let body = self.take_body();
box_async! {
let body = await!(body.into_vec()).client_err()?;
Ok(serde_qs::from_bytes(&body).map_err(|e| err_fmt!("could not decode form: {}", e)).client_err()?)
Ok(serde_urlencoded::from_bytes(&body).map_err(|e| err_fmt!("could not decode form: {}", e)).client_err()?)
}
}

Expand Down Expand Up @@ -50,6 +50,8 @@ pub fn form<T: serde::Serialize>(t: T) -> Response {
http::Response::builder()
.status(http::status::StatusCode::OK)
.header("Content-Type", "application/x-www-form-urlencoded")
.body(Body::from(serde_qs::to_string(&t).unwrap().into_bytes()))
.body(Body::from(
serde_urlencoded::to_string(&t).unwrap().into_bytes(),
))
.unwrap()
}

0 comments on commit d76a6d2

Please sign in to comment.