Skip to content

feat(event_handlers) Add support for returning dict, status-code tuples from resolvers #1853

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

Merged
merged 5 commits into from
Jan 24, 2023

Conversation

theoutsider24
Copy link
Contributor

Issue number:
#1845

Summary

Changes

The response handling in api gateway has been extended to handle dict, status-code tuples

User experience

Endpoints with non-200 status code no longer need to manually build Response objects, they can simply return a dict and status code

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change? No

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

theoutsider24 and others added 2 commits January 19, 2023 11:56
Support returning dict responses and status codes from api gateway route functions

Signed-off-by: Matthew Coyle <[email protected]>
@theoutsider24 theoutsider24 requested a review from a team as a code owner January 23, 2023 16:34
@theoutsider24 theoutsider24 requested review from heitorlessa and removed request for a team January 23, 2023 16:34
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 23, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Jan 23, 2023

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our AWS Lambda Powertools Discord: Invite link

Copy link
Contributor

@rubenfonseca rubenfonseca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theoutsider24 thank you for opening this PR!

Two asks:

  • can you please try to fix the tests? I believe we need some type updates to the tests
  • would you mind adding an update to the docs with the new use case?

We would love if you could help us with this, but otherwise we would be happy to assist :)

@theoutsider24
Copy link
Contributor Author

@rubenfonseca Thanks for the comments!

I've fixed that issue with the type-hinting
Regarding the docs - where do you think the most appropriate place would be to mention it? I couldn't see a place that seemed obvious so I just included it in some existing examples that seemed relevant

@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jan 24, 2023
@rubenfonseca rubenfonseca self-requested a review January 24, 2023 11:49
@rubenfonseca rubenfonseca merged commit 4f7bebb into aws-powertools:develop Jan 24, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Jan 24, 2023

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

@leandrodamascena
Copy link
Contributor

Thank you so much for this PR @theoutsider24! Ruben updated the documentation and we merged it!

@theoutsider24
Copy link
Contributor Author

That's awesome! Thanks so much for your help guys, really pleased I was able to contribute and I look forward to using the feature myself 💪

@rubenfonseca
Copy link
Contributor

This is now released under 2.7.0 version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation event_handlers size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Return response and status code from APIGatewayRestResolver routes
3 participants