pub struct MiddlewareStack { /* private fields */ }Expand description
Ordered stack of middleware layers implementing the onion model.
Implementations§
Source§impl MiddlewareStack
impl MiddlewareStack
pub fn new() -> Self
Sourcepub fn push(&mut self, layer: impl ProxyLayer + 'static)
pub fn push(&mut self, layer: impl ProxyLayer + 'static)
Push a layer onto the stack. Layers are processed in insertion order for requests and reverse order for responses.
Sourcepub async fn process_request(
&self,
request: ProxyRequest,
) -> ProxyResult<Result<(ProxyRequest, usize), ProxyResponse>>
pub async fn process_request( &self, request: ProxyRequest, ) -> ProxyResult<Result<(ProxyRequest, usize), ProxyResponse>>
Process a request through all layers. Returns the (possibly modified) request and the index of the deepest layer reached, or a short-circuit response.
Sourcepub async fn process_response(
&self,
response: ProxyResponse,
depth: usize,
) -> ProxyResult<ProxyResponse>
pub async fn process_response( &self, response: ProxyResponse, depth: usize, ) -> ProxyResult<ProxyResponse>
Process a response back through layers in reverse order.
depth is the number of layers the request passed through.
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MiddlewareStack
impl !RefUnwindSafe for MiddlewareStack
impl Send for MiddlewareStack
impl Sync for MiddlewareStack
impl Unpin for MiddlewareStack
impl UnsafeUnpin for MiddlewareStack
impl !UnwindSafe for MiddlewareStack
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