Skip to content

Make sure example handlers use a structured event type #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2020

Conversation

rib
Copy link
Contributor

@rib rib commented Mar 17, 2020

Description of changes:

This is a documentation (and examples) tweak to consider that lambda handlers need to use a structured type for their event data since Serde will try and deserialize a JSON document into that type and that won't work with a String type which the current examples use.

By submitting this pull request

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I confirm that I've made a best effort attempt to update all relevant documentation.

@davidbarsky davidbarsky self-assigned this Mar 17, 2020
@davidbarsky davidbarsky self-requested a review March 17, 2020 17:21
Internally the request event is effectively deserialized using:

  let event = serde_json::from_slice<T>(&body)

where `T` is the type used for the handler's event type. If this is a
String then Serde will fail to deserialize the JSON input (it won't ever
just be a string).

Handler's should use a structured type for the event that Serde will
be able to deserialize the incoming JSON event data into, so this
updates the examples to use serde_json::Value.
@rib rib force-pushed the wip/rib/structured-event-types branch from 97296f8 to d51560f Compare March 17, 2020 17:49
@davidbarsky davidbarsky merged commit ebc5474 into awslabs:master Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants