pub trait IHttpContext: IClaimsExt + Send {
// Required methods
fn request(&self) -> &dyn IHttpRequest;
fn request_mut(&mut self) -> &mut dyn IHttpRequest;
fn response(&self) -> &dyn IHttpResponse;
fn response_mut(&mut self) -> &mut dyn IHttpResponse;
// Provided method
fn take_early_error(&mut self) -> Option<Error> { ... }
}Expand description
HTTP context encapsulating the request, response, and service provider for the duration of a single HTTP request.
Extends IClaimsExt so middleware can store/retrieve auth claims.
Analogous to ASP.NET Core’s HttpContext.
Required Methods§
fn request(&self) -> &dyn IHttpRequest
fn request_mut(&mut self) -> &mut dyn IHttpRequest
fn response(&self) -> &dyn IHttpResponse
fn response_mut(&mut self) -> &mut dyn IHttpResponse
Provided Methods§
Sourcefn take_early_error(&mut self) -> Option<Error>
fn take_early_error(&mut self) -> Option<Error>
Take a request rejection recorded while the context was built.
The host records failures it can detect from the request line alone —
currently an oversized declared Content-Length — instead of writing a
response eagerly. The request then still travels through the middleware
pipeline (CORS, security headers, access log, metrics, rate limiting)
and the innermost handler turns the value into the normal error
response. A context without such a record returns None.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".