Skip to content

Commit ebc5474

Browse files
authored
docs: ensure example handlers use a structured event type (#213)
1 parent dd4cb4a commit ebc5474

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

lambda/examples/hello-with-ctx.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use lambda::lambda;
2+
use serde_json::Value;
23

34
type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
45

56
#[lambda]
67
#[tokio::main]
7-
async fn main(event: String) -> Result<String, Error> {
8+
async fn main(event: Value) -> Result<Value, Error> {
89
Ok(event)
910
}

lambda/examples/hello-without-macro.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use lambda::handler_fn;
2+
use serde_json::Value;
23

34
type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
45

@@ -9,6 +10,6 @@ async fn main() -> Result<(), Error> {
910
Ok(())
1011
}
1112

12-
async fn func(event: String) -> Result<String, Error> {
13+
async fn func(event: Value) -> Result<Value, Error> {
1314
Ok(event)
1415
}

lambda/examples/hello.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use lambda::lambda;
2+
use serde_json::Value;
23

34
type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
45

56
#[lambda]
67
#[tokio::main]
7-
async fn main(event: String) -> Result<String, Error> {
8+
async fn main(event: Value) -> Result<Value, Error> {
89
Ok(event)
910
}

lambda/src/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323
//!
2424
//! ```no_run
2525
//! use lambda::lambda;
26+
//! use serde_json::Value;
2627
//!
2728
//! type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
2829
//!
2930
//! #[lambda]
3031
//! #[tokio::main]
31-
//! async fn main(event: String) -> Result<String, Error> {
32+
//! async fn main(event: Value) -> Result<Value, Error> {
3233
//! Ok(event)
3334
//! }
3435
//! ```
@@ -136,6 +137,7 @@ where
136137
/// # Example
137138
/// ```no_run
138139
/// use lambda::handler_fn;
140+
/// use serde_json::Value;
139141
///
140142
/// type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
141143
///
@@ -146,8 +148,8 @@ where
146148
/// Ok(())
147149
/// }
148150
///
149-
/// async fn func(s: String) -> Result<String, Error> {
150-
/// Ok(s)
151+
/// async fn func(event: Value) -> Result<Value, Error> {
152+
/// Ok(event)
151153
/// }
152154
/// ```
153155
pub async fn run<A, B, F>(handler: F) -> Result<(), Err>

0 commit comments

Comments
 (0)