derks/drest — Issue #5: Add ability to set custom HTTP headers to a Resource
Author: aalcock
Created: 2012-03-08 06:52:05+00:00
State: open

I need to set an HTTP Header in my requests to
ACCEPT: application/json

to tell the REST server to serve me JSON (rather then HTML or XML). There does not appear to be a simple way to do this. I poked around and have found I can do this:

>>> api.add_resource('users')
>>> api.users._request.add_header("accept", "application/json")

This works a charm, but the _request attribute is being marked as private to the resource, so I shouldn't really do this.