January 2019
Intermediate to advanced
520 pages
14h 32m
English
The handler performs the same logic as the original example, but it is completely rewritten with Rust and the lambda_runtime crate. Look at the implementation of the handler function:
fn handler(event: Request, _: Context) -> Result<Response, HandlerError> { let region = Region::default(); let client = DynamoDbClient::new(region); let username = event .request_context .authorizer .claims .get("cognito:username") .unwrap() .to_owned(); debug!("USERNAME: {}", username); let ride_id = Uuid::new_v4().to_string(); let request: RequestBody = serde_json::from_str(&event.body).unwrap(); let unicorn = find_unicorn(&request.pickup_location); record_ride(&client, &ride_id, &username, &unicorn).unwrap(); let body = ResponseBody { ride_id: ride_id.clone(), ...Read now
Unlock full access