2 releases
Uses old Rust 2015
0.1.1 | Jul 16, 2017 |
---|---|
0.1.0 | May 25, 2017 |
#8 in #named-fields
4KB
Query Param Group
Combined query parameters for Rocket
Usage
extern crate query_param_group;
use query_param_group::{NamedFields, QueryParamGroup};
#[derive(FromForm)]
struct LimitParam {
limit: i32,
}
impl NamedFields for LimitParam {
const FIELDS: &'static [&'static str] = &["limit"];
}
#[derive(FromForm)]
struct UserNameParam {
usercount: i32,
}
impl NamedFields for UserNameParam {
const FIELDS: &'static [&'static str] = &["usercount"];
}
#[get("/users?<query_params>")]
fn get_users(
query_params: QueryParamGroup<(LimitParam, UserNameParam)>
) -> i32 {
let qp = query_params.get();
// now, for some nonsensical code!
qp.0.limit + qp.1.usercount
}
Thanks
Sergio Benitez helped start me off on the right path!
Dependencies
~6.5MB
~137K SLoC