-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add JSONResponse class #2569
Add JSONResponse class #2569
Conversation
Codecov ReportBase: 87.825% // Head: 87.853% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #2569 +/- ##
=============================================
+ Coverage 87.825% 87.853% +0.027%
=============================================
Files 71 73 +2
Lines 5380 5450 +70
Branches 897 903 +6
=============================================
+ Hits 4725 4788 +63
- Misses 474 477 +3
- Partials 181 185 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Just thought about this... what if someone does EDIT: Only solution I've been able to come up with for this is making |
Alright, I've approached this differently. Main difference is that now the body doesn't get set when the raw_body is set, and instead it is generated "on-the-fly" when accessing the attribute. This leaves us with the following outcome:
Only "drawback" is that Let me know your thoughts @ahopkins and if you're happy with it I'll write the tests for it. |
Another potentially breaking change: Currently a However, we could potentially leave this in only for a deprecation period and then remove it (not a fan of it however). Thoughts welcome. |
Remind me... where did we settle on the API for this? |
You suggested doing a That said, we could potentially add the "common methods" that you mentioned previously, such as |
@ahopkins API now should be as agreed 😎 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The json
convenience method needs its return type updated.
It is updated, I believe? https://github.com/sanic-org/sanic/pull/2569/files#diff-9e98d5a6f92def2f06f426094980026882610a5e8d8215b9b291b58620f0f15fR50-R57 |
Ahh the typehint! Done. |
Adds a new JSONResponse class that's returned for JSON responses which introduces some new JSON utilities, such as accessing the raw JSON body and the ability to modify it directly.