A Provider is the equivalent to a Consumer only that it transforms the request handler’s resulting model into a serialization requested from the client. The client is then able to request a certain serialization using the Accept header in her request.
Defining providers for a request handler is done using the provides decorator on the class definition:
@s.provides(s.MediaType.ApplicationJson)
class MyHandler(s.RequestHandler):
pass
A provider can be created equivalently to a consumer:
class JsonProvider(ConsumerBase):
CONTENT_TYPE = ContentType(MediaType.ApplicationJson)
def provide(self, model, handler):
handler.write(model.validate())
For Producers the same remarks about the content type hold as for the Consumers.