pub struct KeelMiddleware { /* private fields */ }Expand description
A Middleware that wraps every request in the keel-core Engine chain.
Owns a cloned reqwest::Client to send attempts itself (module docs
explain why: Next/Extensions cannot cross into
keel_core::Engine::execute’s effect closure under #[async_trait]’s
Send-boxing requirement).
Add it as the last middleware (or the only one) so no transport-adjacent middleware after it is skipped:
keel::init()?;
let raw = reqwest::Client::new();
let client = reqwest_middleware::ClientBuilder::new(raw.clone())
.with(keel::KeelMiddleware::new(raw))
.build();
let resp = client.get("https://api.example.com/orders").send().await?;Implementations§
Source§impl KeelMiddleware
impl KeelMiddleware
Sourcepub fn new(client: Client) -> Self
pub fn new(client: Client) -> Self
client is the reqwest::Client used to actually send every
attempt (cloning a reqwest::Client is cheap — it’s an Arc
internally — so passing the same client you built the
ClientWithMiddleware from is the normal usage).
Trait Implementations§
Source§impl Clone for KeelMiddleware
impl Clone for KeelMiddleware
Source§fn clone(&self) -> KeelMiddleware
fn clone(&self) -> KeelMiddleware
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KeelMiddleware
impl Debug for KeelMiddleware
Source§impl Middleware for KeelMiddleware
impl Middleware for KeelMiddleware
Source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: Request,
_extensions: &'life1 mut Extensions,
_next: Next<'life2>,
) -> Pin<Box<dyn Future<Output = MwResult<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: Request,
_extensions: &'life1 mut Extensions,
_next: Next<'life2>,
) -> Pin<Box<dyn Future<Output = MwResult<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Invoked with a request before sending it. If you want to continue processing the request,
you should explicitly call
next.run(req, extensions). Read moreAuto Trait Implementations§
impl !RefUnwindSafe for KeelMiddleware
impl !UnwindSafe for KeelMiddleware
impl Freeze for KeelMiddleware
impl Send for KeelMiddleware
impl Sync for KeelMiddleware
impl Unpin for KeelMiddleware
impl UnsafeUnpin for KeelMiddleware
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more