aws-lambda-events icon indicating copy to clipboard operation
aws-lambda-events copied to clipboard

Add Default derive for structs that can support it

Open calavera opened this issue 3 years ago • 2 comments

Many structs can be used part of the regular function code. It's very cumbersome to create them by hand if you only need to add a few fields, and want to leave the rest as defaults. We should include Default as part of the derivations, or implement it when possible, so it's easier to work with events manually.

A couple of examples that could be simplified:

Ok(ApiGatewayV2httpResponse {
        status_code: 200,
        headers: HeaderMap::new(),
        multi_value_headers: HeaderMap::new(),
        body: Some(Body::Text(response)),
        is_base64_encoded: Some(false),
        cookies: vec![],
    })

https://github.com/cargo-lambda/cargo-lambda/blob/main/crates/cargo-lambda-watch/src/trigger_router.rs#L98-L132

calavera avatar Jun 21 '22 15:06 calavera

I'm up for doing some of these.

sdd avatar Jun 26 '22 11:06 sdd

This would remove a massive amount of boilerplate. 👍🏻

DaleLJefferson avatar Jul 12 '22 14:07 DaleLJefferson