Skip to main content

origin_http/
client.rs

1use crate::{HttpRequest, HttpResponse};
2use async_trait::async_trait;
3use origin_domain::Result;
4use std::fmt::Debug;
5
6/// The HTTP port.
7///
8/// Implementations own connection pooling, timeouts and redirects. They must translate
9/// transport failures into [`origin_domain::AppError`]:
10///
11/// - no route, DNS failure, connection refused → `Offline` or `Network`
12/// - timeout → `Network`
13/// - anything else → `Network`
14///
15/// They must **not** turn a non-2xx status into an error; that is the caller's decision
16/// via [`HttpResponse::error_for_status`], because some statuses are normal.
17#[async_trait]
18pub trait HttpClient: Debug + Send + Sync + 'static {
19    async fn send(&self, request: HttpRequest) -> Result<HttpResponse>;
20}