Expand description
Procedural macros for pincer declarative HTTP client.
This crate provides the proc-macros for declaring HTTP clients:
#[pincer]- Mark a trait as a pincer HTTP client#[get],#[post],#[put],#[delete],#[patch],#[head],#[options]- HTTP method attributes#[http("VERB /path")]- Custom HTTP method attribute for extensibility#[path],#[query],#[header],#[body],#[form]- Parameter attributes#[derive(Query)]- Derive macro for struct-based query parameters
§Example
ⓘ
use pincer::prelude::*;
#[pincer(url = "https://api.github.com")]
pub trait GitHubApi {
#[get("/users/{username}")]
async fn get_user(&self, #[path] username: &str) -> pincer::Result<User>;
}
// Usage:
let client = GitHubApiClient::builder().build();
let user = client.get_user("octocat").await?;Attribute Macros§
- delete
- Mark a method as a DELETE request.
- get
- Mark a method as a GET request.
- head
- Mark a method as a HEAD request.
- http
- Mark a method with a custom HTTP method and path.
- options
- Mark a method as an OPTIONS request.
- patch
- Mark a method as a PATCH request.
- pincer
- Mark a trait as a pincer HTTP client.
- post
- Mark a method as a POST request.
- put
- Mark a method as a PUT request.
Derive Macros§
- Query
- Derive the
ToQueryPairstrait for a struct.