Skip to main content

Crate api_bones_reqwest

Crate api_bones_reqwest 

Source
Expand description

Reqwest client adapter for api-bones types.

Extension traits that enrich reqwest::RequestBuilder and reqwest::Response with api-bones conveniences:

  • RequestBuilderExt — attach X-Request-Id, Idempotency-Key, and custom Authorization headers.
  • ResponseExt — extract Problem+JSON errors, parse X-RateLimit-* headers, and follow RFC 5988 Link pagination.

§Feature flags

By default this crate enables std and serde on api-bones. Additional api-bones features can be opted into:

FeatureWhat it enables
uuidUUID-typed request/correlation IDs (api-bones/uuid)

§Example

use api_bones_reqwest::{RequestBuilderExt, ResponseExt};

let client = reqwest::Client::new();
let response = client
    .post("https://api.example.com/orders")
    .with_request_id("req-abc-123")
    .with_idempotency_key("idem-xyz")
    .send()
    .await?;

let rate_limit = response.rate_limit_info();
let next_page = response.next_page_url();
let body: serde_json::Value = response.problem_json_or_json().await?;

Traits§

RequestBuilderExt
Extension methods for reqwest::RequestBuilder.
ResponseExt
Extension methods for reqwest::Response.

Functions§

from_response
Extract an api_bones::ApiError from a reqwest::Response.