docs: add missing comment to from_http

Signed-off-by: Alexander Tkachev <sasha64sasha@gmail.com>
This commit is contained in:
Alexander Tkachev 2022-07-24 22:04:25 +03:00
parent 62595ffc3b
commit 2b3c0f1292
1 changed files with 12 additions and 1 deletions

View File

@ -30,7 +30,18 @@ def from_http(
data: typing.Union[str, bytes, None],
data_unmarshaller: types.UnmarshallerType = None,
) -> AnyCloudEvent:
"""
Unwrap a CloudEvent (binary or structured) from an HTTP request.
:param event_type: concrete CloudEvent type to deserialize the event to.
:param headers: the HTTP headers
:type headers: typing.Dict[str, str]
:param data: the HTTP request body. If set to None, "" or b'', the returned
event's data field will be set to None
:type data: typing.IO
:param data_unmarshaller: Callable function to map data to a python object
e.g. lambda x: x or lambda x: json.loads(x)
:type data_unmarshaller: types.UnmarshallerType
"""
if data is None or data == b"":
# Empty string will cause data to be marshalled into None
data = ""