use anyhow::Result;
use lambda_http::IntoResponse;
use lambda_http::Request;
use lambda_http::Service;
use lambda_http::lambda_runtime::Diagnostic;
use lambda_http::tracing;
pub async fn run_lambda<'a, R, S, E>(handler: S) -> Result<()>
where
S: Service<Request, Response = R, Error = E>,
S::Future: Send + 'a,
R: IntoResponse,
E: std::fmt::Debug + Into<Diagnostic>,
{
unsafe {
std::env::set_var("AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH", "true");
};
tracing::init_default_subscriber();
tracing::info!("🌱 listening for requests");
lambda_http::run(handler)
.await
.map_err(|err| anyhow::anyhow!("{}", err))
}