pub trait RequestInterceptor:
Send
+ Sync
+ 'static {
// Required methods
fn intercept(&self, request: Request) -> Request;
fn clone_box(&self) -> Box<dyn RequestInterceptor>;
}Expand description
Trait for intercepting and modifying requests before they reach handlers.
Request interceptors are executed in the order they are registered. Each interceptor receives the request, can modify it, and returns the (potentially modified) request for the next interceptor or handler.
§Example
ⓘ
use rustapi_core::interceptor::RequestInterceptor;
use rustapi_core::Request;
struct LoggingInterceptor;
impl RequestInterceptor for LoggingInterceptor {
fn intercept(&self, req: Request) -> Request {
println!("Request: {} {}", req.method(), req.path());
req
}
}Required Methods§
Sourcefn intercept(&self, request: Request) -> Request
fn intercept(&self, request: Request) -> Request
Intercept and optionally modify the request.
The returned request will be passed to the next interceptor or handler.
Sourcefn clone_box(&self) -> Box<dyn RequestInterceptor>
fn clone_box(&self) -> Box<dyn RequestInterceptor>
Clone this interceptor into a boxed trait object.