-
Notifications
You must be signed in to change notification settings - Fork 327
Closed
Description
In tide version 0.9.0 when a request failed because query() could not parse the query string parameters, it throwed a 400 error with additional information.
Current Behavior
When query() cannot parse the querystring parameters it only throws a 400 Bad Request error without any additional information:
>
< HTTP/1.1 400 Bad Request
< content-length: 0
< date: Tue, 21 Jul 2020 17:03:39 GMT
<
* Connection #0 to host localhost left intact
Code/Gist
#[derive(serde::Deserialize)]
struct FailingParams {
requestor: String,
selections: std::collections::HashMap<String, String>,
quantities: Vec<i32>,
}
async fn handle_endpoint(req: tide::Request<()>) -> tide::Result {
let queries: FailingParams = req.query()?;
let mut res = tide::Response::new(tide::StatusCode::Ok);
res.set_body("ok");
Ok(res)
}
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
let mut address = String::from("127.0.0.1:");
address.push_str("5000");
let mut app = tide::new();
app.at("/").get(|_| async { Ok("Healthy") });
app.at("/v1/endpoint").get(handle_endpoint);
app.listen(address).await?;
Ok(())
}
Expected behavior/code
Same behaviour as version 0.9.0:
curl "http://localhost:5000/v1/endpoint?requestor=test":
< HTTP/1.1 400 Bad Request
< content-length: 42
< date: Tue, 21 Jul 2020 18:00:01 GMT
< content-type: text/plain;charset=utf-8
<
failed with reason: missing field `selections`* Connection #0 to host localhost left intact
Environment
- Rust toolchain version(s): stable-x86_64-pc-windows-gnu
- OS: Windows 10
Possible Solution
Add error message like in tide's version 0.9.0
Additional context/Screenshots
None
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels