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

Add API to easily send JSON as web response body #1732

Closed
fafhrd91 opened this issue Mar 20, 2017 · 8 comments
Closed

Add API to easily send JSON as web response body #1732

fafhrd91 opened this issue Mar 20, 2017 · 8 comments
Labels
Milestone

Comments

@fafhrd91
Copy link
Member

we may need to reconsider adding "json=" parameter to web.Response class.

more discussions in #1726 and #592

@fafhrd91 fafhrd91 added this to the 2.1 milestone Mar 20, 2017
@fafhrd91
Copy link
Member Author

it is about convenience.

Of course for proper handling of json encoding with versioning and custom serialization proper middle should be used.

@fafhrd91
Copy link
Member Author

@alex-eri
Copy link
Contributor

Why is this better than aiohttp.web.json_response?

@fafhrd91
Copy link
Member Author

it is not better it is convenient.

@fafhrd91 fafhrd91 modified the milestones: 2.2, 2.1 May 2, 2017
@asvetlov
Copy link
Member

asvetlov commented May 3, 2017

It's like moving in backward direction.
web.Response is a class for sending either text or binary data back to client.

Honestly I have a feeling than the class is overcomplicated (take a look in Response.__init__ code).
For sake of clean architecture we need two classes: TextResponse and BinaryResponse.
But I can live with current state.

Adding a new parameter leads to combinatorial explosion.

@fafhrd91
Copy link
Member Author

fafhrd91 commented May 3, 2017

I am ok with this. we can close this ticket

@AraHaan
Copy link
Contributor

AraHaan commented May 3, 2017

I agree with @asvetlov on aiohttp needing 2 response classes and having the json response part of TextResponse. I would do it myself but I am not sure what parts are for binary data and what parts are for text data or both. That is how complicated it is. However there might be places where binary data is sent with json data. In that case it might break unless there is a way to avoid it?

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants