Build Status Rust version

QueryParams Derive

Rust custom derive to automatically implement serialization to http query params for arbitrary structs. A simple #[derive(QueryParams)] will generate a function to_query_params for your struct.

How it Works

```rust

[macro_use]

extern crate query_params;

[derive(QueryParams)]

struct PullRequestsParametersApi { page: i32, sort: bool, direction: String, state: Vec, // .. other interesting fields .. }

fn main() { let pr = PullRequestsParametersApi { page: 2, sort: true, direction: "asc", state: vec!["open".tostring(), "closed".tostring()], }

println!("{}", pr.to_query_params()); // => ?page=2&sort=true&direction=asc&state=open,closed

} ```

Get Started

It's as simple as two steps:

  1. Add query_params to your Cargo.toml

    cargo add derive_builder

  2. Annotate your struct with #[derive(QueryParams)]

Disclaimer :exclamation:

Documentation

Detailed explaination of all features and tips for troubleshooting.

Contribution

Feel free to make a pull request :smiley: