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

Provide a temporal HttpResponse typed argument to views #336

Merged
merged 5 commits into from
May 24, 2022

Conversation

SmileyChris
Copy link
Contributor

Provide a temporal response object to views allowing the altering of headers / cookies.
(needs docs, just pushing for initial review)

Fixes #106 and fixes #117

e.g.

@api.post("/boop")
def boop(request, response: HttpResponse):
    response.set_cookie("beep", "boop")
    return True

@SmileyChris
Copy link
Contributor Author

Have you had a chance to look at the idea here, @vitalik ? I can write some docs up if it's something you want to proceed with.

@vitalik
Copy link
Owner

vitalik commented Feb 6, 2022

Hi @SmileyChris
Yes, this will likely land in the next release

@SmileyChris
Copy link
Contributor Author

I'll write some docs up then. It'd be nice to avoid conflicts by getting my docs branch in first ;)

@SmileyChris
Copy link
Contributor Author

SmileyChris commented Mar 28, 2022

The only additional thing I've been thinking about in regards to this is having the status code set in the temporal response be used, rather than overwritten. We could deprecate the 2-part tuple behaviour of passing (status_code, body) and just use this new response object as the canonical way of specifying the response status code.

This doesn't have to happen as part of this initial pull, just wanted to bring this up as a related idea.

Copy link
Contributor

@stephane stephane left a comment

Choose a reason for hiding this comment

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

LGTM

@vitalik vitalik merged commit 33357e4 into vitalik:master May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cookies and responses Provide a way to specify response headers
3 participants