3👍
You could subclass piston.resource.Resource
, and add whatever header you want in the __call__
method.
from piston.resource import Resource
class MyResource(Resource):
def __call__(self, request, *args, **kwargs):
resp = super(MyResource, self).__call__(request, *args, **kwargs)
resp['HEADER'] = "abc123"
return resp
Then, in your urls.py:
def BasicResource(handler):
return resource.MyResource(handler=handler, authentication=basic)
your_handler = BasicResource(YourHandlerClass)
another_handler = BasicResource(AnotherHandlerClass)
Source:stackexchange.com