hyperlane_core/context/struct.rs
1use super::*;
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 request, response, and any custom attributes.
7#[derive(Clone, CustomDebug, Data, DisplayDebug)]
8pub struct Context {
9 /// The incoming HTTP request.
10 pub request: Request,
11 /// The outgoing HTTP response.
12 pub response: Response,
13 /// Parameters extracted from the route path.
14 pub route_params: RouteParams,
15 /// The original wire request target, before routing or query-map conversion.
16 ///
17 /// The target is read on every request and written on every request, so it
18 /// lives in its own field rather than in the attribute map: the map would
19 /// cost a hash, an allocation and a downcast for every request, and the
20 /// attribute map is for the attributes the application sets.
21 #[get_mut(pub(super))]
22 #[set(pub(super))]
23 pub(super) original_target: Option<String>,
24 /// Whether the original wire method was HEAD, independent of route rewrites.
25 #[get(pub(crate))]
26 #[get_mut(skip)]
27 #[set(pub(crate))]
28 pub(crate) original_head: Option<bool>,
29 /// A collection of custom attributes for sharing data within the request lifecycle.
30 pub attributes: ThreadSafeAttributeStore,
31}