Since all the JSON formatting is done by the strategy classes, the job of the responder class becomes much simpler: all this class needs to do is to accept the incoming environment information, data, error message, and HTTP status code. All of this information is passed to the responder by the action script. We start by importing the strategies and initializing the key properties:
# web.responder.rest
from web.responder.strategy.jsend import JsendStrategy
from web.responder.strategy.json_api import JsonApiStrategy
from web.responder.strategy.hal_json import HalJsonStrategy
class RestResponder :
json_strategy = None
header_accept = None
The most important property definition determines what formatting types are accepted. This property is in the form of a dictionary and is used to match the information in the incoming HTTP Accept header (https://tools.ietf.org/html/rfc2616#section-14.1) against the supported MIME types:
accepted_types = {
&apos...