Expand description
An HTTP client for Churust applications.
A service usually has to call other services: an identity provider, a payment gateway, its own sibling. This is the client for that, built on the same hyper the server side runs on, so a Churust binary carries one HTTP implementation rather than two.
use churust_client::Client;
let client = Client::new();
let res = client.get("http://127.0.0.1:8080/health").send().await?;
assert_eq!(res.status().as_u16(), 200);
println!("{}", res.text()?);§Scope
Deliberately small: build a request, send it, read the response. Retries, circuit breaking, service discovery and tracing propagation are policy, and policy belongs to the application that knows what it is calling. What the client does own is the part that is easy to get wrong on your own: pooled connections, an enforced timeout, a bounded response body, and refusing to follow a redirect into a different scheme.
§Responses are bounded
A response body is read into memory up to Client::max_response_bytes
(16 MiB by default) and refused past it. An unbounded read from a service
you do not control is how one slow dependency becomes your own out-of-memory
kill.
Structs§
- Client
- A pooled HTTP client.
- Request
Builder - A request under construction. Finish it with
send. - Response
- A response, with its body already read.
Enums§
- Client
Error - Everything that can go wrong sending a request.