Skip to content
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

Feature request: Support cookies in Lambda function response for format 2.0 #1192

Closed
1 of 2 tasks
eflopez opened this issue Apr 29, 2022 · 6 comments · Fixed by #1455
Closed
1 of 2 tasks

Feature request: Support cookies in Lambda function response for format 2.0 #1192

eflopez opened this issue Apr 29, 2022 · 6 comments · Fixed by #1455
Assignees
Labels
feature-request feature request v2

Comments

@eflopez
Copy link

eflopez commented Apr 29, 2022

Use case

I am using the Router class to setup some resolvers for use with APIGatewayHttpResolver, and I would like to be able to set cookies in my customised Response object, but this is not currently possible.

According to the APIGateway response documentation, the format for this is

{
    "cookies" : ["cookie1", "cookie2"],
    "isBase64Encoded": true|false,
    "statusCode": httpStatusCode,
    "headers": { "headername": "headervalue", ... },
    "body": "Hello from Lambda!"
}

Solution/User Experience

Would be great to be able to just be able to do something like

    return Response(
        status_code=418,
        cookies=["cookie1", "cookie2"],
        content_type="application/json",
        body=payload,
        headers=custom_headers,
    )

Alternative solutions

No response

Acknowledgment

@eflopez eflopez added feature-request feature request triage Pending triage from maintainers labels Apr 29, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 29, 2022

Thanks for opening your first issue here! We'll come back to you as soon as we can.

@michaelbrewer
Copy link
Contributor

Good idea! There are more cumbersome way, but format 2.0 does make it easier. Once this has been "approved" / "triaged", it should be an easy addition to the API GW handler.

michaelbrewer added a commit to gyft/aws-lambda-powertools-python that referenced this issue Apr 30, 2022
Changes:
- Add cookies field in Response
- For http api gateway format 2.0 responses serialize to cookies
- For alb and rest api use multiValueHeaders

closes aws-powertools#1192
@michaelbrewer
Copy link
Contributor

@eflopez For discussion purpose i created a PR #1196

This will also allow for a more convenient method to set cookies for ALB, Http and Rest apis.

@heitorlessa heitorlessa changed the title Feature request: Support Lambda function response for format 2.0 Feature request: Support cookies in Lambda function response for format 2.0 May 16, 2022
@heitorlessa heitorlessa removed the triage Pending triage from maintainers label Jun 13, 2022
@heitorlessa heitorlessa added the help wanted Could use a second pair of eyes/hands label Aug 1, 2022
@heitorlessa heitorlessa removed the help wanted Could use a second pair of eyes/hands label Aug 10, 2022
@heitorlessa
Copy link
Contributor

Removing help wanted as @rubenfonseca will start working on this next week.

@heitorlessa heitorlessa linked a pull request Aug 17, 2022 that will close this issue
7 tasks
@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label Aug 29, 2022
@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Sep 13, 2022
@aws-powertools aws-powertools deleted a comment from github-actions bot Sep 13, 2022
@heitorlessa heitorlessa added the v2 label Sep 19, 2022
@rubenfonseca rubenfonseca self-assigned this Sep 26, 2022
@heitorlessa
Copy link
Contributor

Closing as we're wrap to launch V2

@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request feature request v2
Projects
None yet
5 participants