cdk-http-client
HTTP client abstraction for the Cashu Development Kit (CDK).
This crate provides an HTTP client wrapper and transport trait abstraction that allows other CDK crates to avoid direct dependencies on a specific backend.
Features
bitreq(default) - enables the bitreq backend and transport implementationreqwest- enables the reqwest backend and transport implementationtor- enables the Tor transport implementation
Native builds must enable at least one HTTP backend: bitreq or reqwest.
bitreq is the default. cdk-common/http enables it, and cdk's wallet and
mint features depend on that, so any CDK build that uses HTTP gets a working
client out of the box — including cdk --no-default-features --features wallet.
Depending on this crate directly with --no-default-features and selecting no
backend is unsupported and fails at compile time with a clear error.
The backend features are additive. When both bitreq and reqwest are enabled,
reqwest takes precedence and is the single backend compiled in (it is a strict
superset, adding SOCKS proxy and invalid-certificate support). This means Cargo
feature unification across a dependency graph never produces a build conflict: a
crate that enables reqwest and another that enables bitreq resolve to
reqwest.
Use default bitreq backend:
Use reqwest backend (standalone):
To use the reqwest backend with CDK, add a direct cdk-http-client dependency
with the reqwest feature. It takes precedence wherever it is enabled, so there
is no need to disable default features:
[]
= { = "0.17.0", = ["wallet"] }
= { = "0.17.0", = ["reqwest"] }
Usage
use ;
use Deserialize;
async
API
Builder methods (return RequestBuilder):
get(url)- GET request builderpost(url)- POST request builderpatch(url)- PATCH request builder
Convenience methods (return deserialized JSON):
fetch<R>(url)- simple GET returning JSONpost_json<B, R>(url, body)- POST with JSON bodypost_form<F, R>(url, form)- POST with form datapatch_json<B, R>(url, body)- PATCH with JSON body
Transport types:
Transport- trait consumed by higher-level CDK componentsAsync- default transport using the selected backendBitreqTransport- alias forAsyncwhenbitreqis selectedReqwestTransport- alias forAsyncwhenreqwestis enabledTorAsync- Tor-specific transport (enabled bytorfeature)