mattupstate/flask-jwt — pull request #13 by sloria (2014-05-28 03:08:46+00:00)
Title: Add response_handler hook/decorator

Adds a `response_handler` hook that allows for custom formatting of the output response for the auth endpoint.

Example

```python
@jwt.response_handler
def handle_response(token):
return jsonify({'mytoken': token})

# POST /auth => {"mytoken": 'abc123...'}
```

This control over the response is absolutely necessary when using libraries that automatically JSONify the return value of your views. For example, [Flask-API](https://github.com/tomchristie/flask-api) and [Flask-RESTful](https://github.com/twilio/flask-restful) extensions expect views to return dictionaries. The extensions handle the "jsonification".

Without a means for overriding flask-jwt's response behavior, your token payload gets jsonified twice!