reqwest-rest 0.1.0

An opinionated utility to help with creating (and configuring) one-off idiomatic REST API clients.
Documentation
//! An opinionated utility to help with creating one-off idiomatic REST API clients.
//!
//! [`RestClient`] wraps a `reqwest_middleware::ClientWithMiddleware` and provides a uniform API
//! for making all types of http-json requests and parsing responses as json if possible.
//! Errors are rich and retain request context, and allow for further processing of unparseable responses.
//!
//! Typically means you can define the schema using serde-compatible types, and implement
//! an RPC-like client over `RestClient` with minimal boilerplate, where each call is 1-2 lines.
//! To do further API-specific processing of error responses, you can use `map_err` and match against
//! `Error::Response`, and do whatever you need to with the body of that response.
//!
//! Separately from this, [`CommonConfig`] helps to reduce boilerplate when setting up timeouts
//! and retries with backoff, which is appropriate in most situations that you make rest requests.
//!
//! [`LoggingRetryableStrategy`] is a reqwest-retry `RetryStrategy` which logs additional information
//! when requests need to be retried, and is attached when using `CommonConfig`.

#![deny(missing_docs)]

pub use reqwest;
pub use reqwest_middleware;

#[cfg(feature = "reqwest-retry")]
pub use reqwest_retry;
#[cfg(feature = "reqwest-retry")]
pub use retry_policies;

mod rest_client;
pub use rest_client::{
    ClientWithMiddleware, Error, HeaderMap, Method, ParseError, ReqwestError,
    ReqwestMiddlewareError, RestClient, SerdeJsonError, SerdeQsError, Url, join_url,
};

#[cfg(feature = "reqwest-retry")]
mod common_config;
#[cfg(feature = "reqwest-retry")]
pub use common_config::CommonRestConfig;

#[cfg(feature = "reqwest-retry")]
mod retry_strategy;
#[cfg(feature = "reqwest-retry")]
pub use retry_strategy::LoggingRetryableStrategy;