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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! # Armature Lambda
//!
//! AWS Lambda runtime adapter for Armature applications.
//!
//! This crate runs an HTTP handler on AWS Lambda behind API Gateway, ALB, or
//! Lambda Function URLs, translating the incoming event into a
//! [`LambdaRequest`] and the handler's [`LambdaResponse`] back out.
//!
//! ## What this crate does and does not do
//!
//! [`LambdaRuntime`] drives any type implementing [`RequestHandler`], which is
//! stated in this crate's own [`LambdaRequest`]/[`LambdaResponse`] types. It
//! does **not** convert to or from `armature_core::HttpRequest` /
//! `HttpResponse`, and there is no blanket implementation for an Armature
//! `Application` — wiring one up is the application author's job, most easily
//! via `impl_lambda_handler!` (see its documentation for the exact shape it
//! expects).
//!
//! ## Quick Start
//!
//! ```rust,ignore
//! use armature_lambda::{LambdaRequest, LambdaResponse, LambdaRuntime};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), lambda_runtime::Error> {
//! // Initialize tracing for CloudWatch
//! armature_lambda::init_tracing();
//!
//! let handler = |req: LambdaRequest| async move {
//! LambdaResponse::ok(format!("Hello from {}!", req.path))
//! };
//!
//! LambdaRuntime::new(handler).run().await
//! }
//! ```
//!
//! ## Deployment
//!
//! Build for Lambda with:
//!
//! ```bash
//! # Install cargo-lambda
//! cargo install cargo-lambda
//!
//! # Build for Lambda
//! cargo lambda build --release
//!
//! # Deploy
//! cargo lambda deploy
//! ```
pub use ;
pub use ;
pub use LambdaResponse;
pub use ;
// Re-export lambda types
pub use lambda_http;
pub use lambda_runtime;
// Re-exported so `impl_lambda_handler!` can name the attribute macro through
// `$crate`. Without this the macro would only expand in crates that happen to
// depend on `async-trait` themselves and under that exact name.
pub use async_trait;
/// Initialize tracing for Lambda/CloudWatch.
///
/// This sets up structured JSON logging suitable for CloudWatch Logs.
/// Initialize tracing with a custom log level.