Function mu_alb::runtime::listen_events [−][src]
pub async fn listen_events<F, Fut, A, B>(handler: F) -> RuntimeResult where
F: Fn(A) -> Fut + Sync + Send,
Fut: Future<Output = B> + Send,
A: AlbDeserialize<A> + Send,
B: AlbSerialize,
Expand description
Listen to ALB events. Unlike mu_runtime::listen_events, this method expects you to respect the AWS Application Load Balancer contract by returning the appropriate response (defined by aws_lambda_events::event::alb::AlbTargetGroupRequest).
It’s expected the handler
argument to be an async function, as exemplified below.
use mu_alb::*; use aws_lambda_events::event::alb::{ AlbTargetGroupRequest, AlbTargetGroupResponse }; #[tokio::main] async fn main() -> RuntimeResult { listen_events(|req: AlbTargetGroupRequest| { say_hello() }).await } async fn say_hello() -> AlbTargetGroupResponse { response::create_as_plain_text( 200, Some("Hello World".to_string())) }