Replies: 4 comments
-
Yes, you can use
|
Beta Was this translation helpful? Give feedback.
-
Thanks for your answer @bnusunny. Two follow-on questions. How is Is it possible to elaborate on what data should I be providing to the functions. How does the JSON payload map to something that the function handler can interpret? |
Beta Was this translation helpful? Give feedback.
-
if you use the
|
Beta Was this translation helpful? Give feedback.
-
Hey Tim! I was in the exact predicament as you a few weeks back.
Yes,
If you are using the curl -v -X POST \
'http://127.0.0.1:9001/lambda-url/<lambda-function-name>' \
-H 'content-type: application/json' \
-d \
"{
\"words\": [\"hello\", \"world\"],
\"number\": 5
}" You should define a struct like so. #[derive(Deserialize)]
struct RequestEvent {
words: Vec<String>,
number: i32
}
async fn handler(event: Request) -> Result<Response<Body>, Error> {
let payload = match event.payload::<RequestEvent>() {
Ok(Some(payload)) => payload,
Ok(None) => {
return Ok(Response::builder()
.status(400)
.body("No body found".into())
.map_err(Box::new)?)
}
Err(err) => {
return Ok(Response::builder()
.status(400)
.body(format!("Error parsing body: {}", err).into())
.map_err(Box::new)?)
}
};
} Ideally, the entire docs should be completely rewritten. To prevent further confusion, anything related to |
Beta Was this translation helpful? Give feedback.
-
I'm slightly confused about how to invoke the HTTP examples on the command line via
cargo lambda invoke
.For example, the
http-axum
example provides a few HTTP accessible paths, but I'm unsure how to reach them.http-basic-lambda
is even more frustrating, because it doesn't accept any arguments, yet theinvoke
sub-command requires that users specific data to sent.What data should I be providing? How do I send GET vs POST requests? Is it possible to simply use
curl
?Beta Was this translation helpful? Give feedback.
All reactions