Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Add Default derive for structs that can support it #104

Closed
calavera opened this issue Jun 21, 2022 · 2 comments · Fixed by #108
Closed

Add Default derive for structs that can support it #104

calavera opened this issue Jun 21, 2022 · 2 comments · Fixed by #108
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@calavera
Copy link
Owner

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 calavera added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jun 21, 2022
@sdd
Copy link
Contributor

sdd commented Jun 26, 2022

I'm up for doing some of these.

@DaleLJefferson
Copy link

This would remove a massive amount of boilerplate. 👍🏻

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants