You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working on several projects that provide a JSON API using WebOb. Currently, however, whenever we use a webob.exc exception to return an error to the user (e.g., webob.exc.HTTPBadRequest) the body of that message is always in a content-type other than what they're expecting (HTML if they don't specify an Accept header, plain-text otherwise). There doesn't seem to be a pleasant, convenient, or simple way to make it use JSON beyond something like (the untested) following code:
This is particularly problematic because we have to redefine all of the exceptions we want to use to doubly inherit from our new sub-classed WSGIHTTPException and the original. It also doesn't handle the fact that we have to basically copy and paste generate_response into our subclass so that we set the appropriate content-type header.
Is it too much to ask to either:
A) Add support for JSON response bodies in WSGIHTTPExceptions, or
B) Make WSGIHTTPException slightly more modular so we can only override parts we need?
Thanks in advance,
The text was updated successfully, but these errors were encountered:
I'm currently working on several projects that provide a JSON API using WebOb. Currently, however, whenever we use a
webob.exc
exception to return an error to the user (e.g.,webob.exc.HTTPBadRequest
) the body of that message is always in a content-type other than what they're expecting (HTML if they don't specify an Accept header, plain-text otherwise). There doesn't seem to be a pleasant, convenient, or simple way to make it use JSON beyond something like (the untested) following code:This is particularly problematic because we have to redefine all of the exceptions we want to use to doubly inherit from our new sub-classed
WSGIHTTPException
and the original. It also doesn't handle the fact that we have to basically copy and paste generate_response into our subclass so that we set the appropriate content-type header.Is it too much to ask to either:
A) Add support for JSON response bodies in
WSGIHTTPException
s, orB) Make
WSGIHTTPException
slightly more modular so we can only override parts we need?Thanks in advance,
The text was updated successfully, but these errors were encountered: