Add support for some "forwarded" headers, included several new attributes and a reworking of some of the existing code to better facilitate sharing and performance. Also clean up a couple tiny nits in the docstrings for the sake of consistency.
31 lines
729 B
Python
31 lines
729 B
Python
import abc
|
|
|
|
import six
|
|
|
|
|
|
@six.add_metaclass(abc.ABCMeta)
|
|
class BaseHandler(object):
|
|
"""Abstract Base Class for an internet media type handler"""
|
|
|
|
@abc.abstractmethod # pragma: no cover
|
|
def serialize(self, obj):
|
|
"""Serialize the media object on a :any:`falcon.Response`
|
|
|
|
Args:
|
|
obj (object): A serializable object.
|
|
|
|
Returns:
|
|
bytes: The resulting serialized bytes from the input object.
|
|
"""
|
|
|
|
@abc.abstractmethod # pragma: no cover
|
|
def deserialize(self, raw):
|
|
"""Deserialize the :any:`falcon.Request` body.
|
|
|
|
Args:
|
|
raw (bytes): Input bytes to deserialize
|
|
|
|
Returns:
|
|
object: A deserialized object.
|
|
"""
|