hyperlane/context/struct.rs
1use crate::*;
2
3/// Represents the internal state of the application context.
4///
5/// This structure holds all the data associated with a single request-response cycle,
6/// including the stream, request, response, and any custom attributes.
7#[derive(Clone, CustomDebug, Data, DisplayDebug)]
8pub struct Context {
9 /// A flag indicating whether the request handling has been aborted.
10 #[get(type(copy))]
11 pub(super) aborted: bool,
12 /// A flag indicating whether the connection has been closed.
13 #[get(type(copy))]
14 pub(super) closed: bool,
15 /// The underlying network stream for the connection.
16 #[get_mut(skip)]
17 #[set(pub(super))]
18 pub(super) stream: Option<ArcRwLockStream>,
19 /// The incoming HTTP request.
20 #[get_mut(skip)]
21 #[set(pub(super))]
22 pub(super) request: Request,
23 /// The outgoing HTTP response.
24 pub(super) response: Response,
25 /// Parameters extracted from the route path.
26 #[get_mut(skip)]
27 #[set(pub(crate))]
28 pub(super) route_params: RouteParams,
29 /// A collection of custom attributes for sharing data within the request lifecycle.
30 #[get_mut(pub(super))]
31 #[set(pub(super))]
32 pub(super) attributes: ThreadSafeAttributeStore,
33 /// The server for accessing server-wide configuration and state.
34 #[get_mut(skip)]
35 #[set(pub(super))]
36 pub(super) server: &'static Server,
37}