HTTP Provider Macro
Generate type-safe HTTP client methods from endpoint definitions.
Usage
Add to your Cargo.toml:
[]
= "0.1.3"
= { = "0.11", = ["json"] }
= { = "1.0", = ["derive"] }
= { = "1.0", = ["full"] }
Define your endpoints:
use http_provider;
use ;
http_provider!;
// Use it
let client = new;
let users = client.get_users.await?;
let user = client.get_users_by_id.await?;
Endpoint Fields
Required:
method: HTTP method (GET, POST, PUT, DELETE)res: Response type (optional, defaults to())
Optional:
path: URL path (e.g., "/users/{id}")path_params: Type for path parametersquery_params: Type for query parametersreq: Request body typeheaders: Header type (e.g.,reqwest::header::HeaderMap)fn_name: Custom function name
Examples
See the examples/ directory:
basic.rs- Simple usageparams.rs- Path and query parametersadvanced.rs- All featuresmocking.rs- Testing with traits
License
MIT OR Apache-2.0