1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use lamedh_runtime::Context;
use std::ops::Deref;
pub(crate) struct LambdaContext(Context);
impl LambdaContext {
pub fn new(context: Context) -> Self {
Self(context)
}
}
impl Deref for LambdaContext {
type Target = Context;
fn deref(&self) -> &Self::Target {
&self.0
}
}
pub trait LambdaConnExt {
fn lambda_context(&self) -> &Context;
}
impl LambdaConnExt for trillium::Conn {
fn lambda_context(&self) -> &Context {
self.state::<LambdaContext>()
.expect("lambda context should always be set inside of a lambda server")
}
}