Skip to content

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 aws: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