keiro/ext.rs
1use crate::Params;
2use hyper::{Body, Request};
3
4pub trait RequestExt {
5 fn params(&self) -> Option<&Params>;
6 fn state<T: Clone + Send + Sync + 'static>(&self) -> Option<&T>;
7}
8
9impl RequestExt for Request<Body> {
10 fn params(&self) -> Option<&Params> {
11 self.extensions().get::<Params>()
12 }
13
14 fn state<T: Clone + Send + Sync + 'static>(&self) -> Option<&T> {
15 self.extensions().get::<T>()
16 }
17}