pub struct MiddlewarePipeline {
pub cors: Option<CorsConfig>,
pub body_limit: Option<BodyLimitConfig>,
pub rate_limiter: Option<RateLimiter>,
pub timeout: Option<TimeoutConfig>,
/* private fields */
}Expand description
The middleware pipeline configuration for a server.
Fields§
§cors: Option<CorsConfig>CORS configuration (applied to all responses).
body_limit: Option<BodyLimitConfig>Body size limit (checked before handler).
rate_limiter: Option<RateLimiter>Rate limiter (checked before handler).
timeout: Option<TimeoutConfig>Request timeout.
Implementations§
Source§impl MiddlewarePipeline
impl MiddlewarePipeline
Sourcepub fn with_cors(self, config: CorsConfig) -> Self
pub fn with_cors(self, config: CorsConfig) -> Self
Add CORS middleware.
Sourcepub fn with_body_limit(self, max_bytes: u64) -> Self
pub fn with_body_limit(self, max_bytes: u64) -> Self
Add body size limit middleware.
Sourcepub fn with_rate_limiter(self, limiter: RateLimiter) -> Self
pub fn with_rate_limiter(self, limiter: RateLimiter) -> Self
Add rate limiting middleware.
Sourcepub fn with_timeout(self, duration: Duration) -> Self
pub fn with_timeout(self, duration: Duration) -> Self
Add request timeout middleware.
Sourcepub async fn pre_handle(
&self,
req: &Request<Incoming>,
) -> Option<Result<Response<Full<Bytes>>, OxiHttpError>>
pub async fn pre_handle( &self, req: &Request<Incoming>, ) -> Option<Result<Response<Full<Bytes>>, OxiHttpError>>
Run pre-handler middleware checks.
Returns Some(response) if middleware short-circuits (e.g. CORS preflight,
rate limit exceeded, body too large). Returns None if the request should
proceed to the handler.
Trait Implementations§
Source§impl Clone for MiddlewarePipeline
impl Clone for MiddlewarePipeline
Source§fn clone(&self) -> MiddlewarePipeline
fn clone(&self) -> MiddlewarePipeline
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 MiddlewarePipeline
impl Debug for MiddlewarePipeline
Auto Trait Implementations§
impl !RefUnwindSafe for MiddlewarePipeline
impl !UnwindSafe for MiddlewarePipeline
impl Freeze for MiddlewarePipeline
impl Send for MiddlewarePipeline
impl Sync for MiddlewarePipeline
impl Unpin for MiddlewarePipeline
impl UnsafeUnpin for MiddlewarePipeline
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