Skip to content
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

Use query from http types #555

Merged
merged 2 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep this method, but it should forward to self.req.query instead.

// 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.