-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Impl
pub fn query_parsed<T: FromStr + 'static>(req: &HttpRequest, name: &str) -> crate::Result<Option<T>>
where
<T as FromStr>::Err: std::error::Error + Send + Sync + 'static,
{
match req.query(name) {
Some(q) => q
.parse::<T>()
.context(format!("Couldn't parse query value: {} for query `{}`", q, name))
.map(|q| Some(q)),
None => Ok(None),
}
}Use:
let page = req.query_parsed::<u64>("page")?.unwrap_or_else(0);Metadata
Metadata
Assignees
Labels
No labels