Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rbalicki2/rocket-query-param-group
Group your Query Params for the Rocket framework
https://github.com/rbalicki2/rocket-query-param-group
Last synced: 4 days ago
JSON representation
Group your Query Params for the Rocket framework
- Host: GitHub
- URL: https://github.com/rbalicki2/rocket-query-param-group
- Owner: rbalicki2
- Created: 2017-05-25T00:40:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-16T23:26:35.000Z (over 7 years ago)
- Last Synced: 2024-10-12T19:08:46.015Z (about 1 month ago)
- Language: Rust
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Query Param Group
> Combined query parameters for Rocket
## Usage
```rust
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?")]
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](github.com/SergioBenitez) helped start me off on the right path!