pub struct RouteContext<State: Clone, E> {
pub path: String,
pub method: String,
pub params: HashMap<String, String>,
pub state: Arc<State>,
pub event: E,
pub lambda_context: Context,
pub route_pattern: String,
}Expand description
Context passed to route handlers containing request information and application state.
This struct provides access to:
- The request path and method
- Path parameters extracted from the URL
- Application state
- The original Lambda event
- Lambda execution context
Fields§
§path: StringThe full request path
method: StringThe HTTP method (GET, POST, etc.)
params: HashMap<String, String>Path parameters extracted from the URL (e.g., {id} -> “123”)
state: Arc<State>Application state shared across all requests
event: EThe original Lambda event
lambda_context: ContextLambda execution context
route_pattern: StringThe route template pattern (e.g., “/quote/{id}”)
Implementations§
Source§impl<State: Clone, E> RouteContext<State, E>
impl<State: Clone, E> RouteContext<State, E>
Sourcepub fn set_otel_span_name(&self) -> &Self
pub fn set_otel_span_name(&self) -> &Self
Helper method to set the OpenTelemetry span name using the route pattern
Sourcepub fn set_otel_attribute(
&self,
key: impl Into<OtelKey>,
value: impl Into<OtelValue>,
) -> &Self
pub fn set_otel_attribute( &self, key: impl Into<OtelKey>, value: impl Into<OtelValue>, ) -> &Self
Helper method to set a single attribute on the current OpenTelemetry span
§Examples
ctx.set_otel_attribute("string_attr", "value");
ctx.set_otel_attribute("int_attr", 42);
ctx.set_otel_attribute("bool_attr", true);Trait Implementations§
Auto Trait Implementations§
impl<State, E> Freeze for RouteContext<State, E>where
E: Freeze,
impl<State, E> RefUnwindSafe for RouteContext<State, E>where
E: RefUnwindSafe,
State: RefUnwindSafe,
impl<State, E> Send for RouteContext<State, E>
impl<State, E> Sync for RouteContext<State, E>
impl<State, E> Unpin for RouteContext<State, E>where
E: Unpin,
impl<State, E> UnwindSafe for RouteContext<State, E>where
E: UnwindSafe,
State: RefUnwindSafe,
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