Skip to content

Commit

Permalink
Merge pull request #555 from plippe/use-query-from-http-types
Browse files Browse the repository at this point in the history
Use query from http types
  • Loading branch information
yoshuawuyts authored May 29, 2020
2 parents d7baf70 + ef42cc1 commit 17b1c5e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 109 deletions.
10 changes: 1 addition & 9 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,7 @@ impl<State> Request<State> {

/// Get the URL querystring.
pub fn query<T: serde::de::DeserializeOwned>(&self) -> crate::Result<T> {
// Default to an empty query string if no query parameter has been specified.
// This allows successful deserialisation of structs where all fields are optional
// when none of those fields has actually been passed by the caller.
let query = self.url().query().unwrap_or("");
serde_qs::from_str(query).map_err(|e| {
// Return the displayable version of the deserialisation error to the caller
// for easier debugging.
crate::Error::from_str(StatusCode::BadRequest, format!("{}", e))
})
self.req.query()
}

/// Take the request body as a `Body`.
Expand Down
100 changes: 0 additions & 100 deletions tests/querystring.rs

This file was deleted.

0 comments on commit 17b1c5e

Please sign in to comment.