-
Notifications
You must be signed in to change notification settings - Fork 58
Consolidating return types #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,8 +55,18 @@ def FromRequest(self, event: event_base.BaseEvent, | |
:return: a CloudEvent | ||
:rtype: event_base.BaseEvent | ||
""" | ||
if not isinstance(data_unmarshaller, typing.Callable): | ||
raise exceptions.InvalidDataUnmarshaller() | ||
|
||
content_type = headers.get( | ||
"content-type", headers.get("Content-Type")) | ||
|
||
for _, cnvrtr in self.__converters.items(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is treating There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I fixed this in #9) |
||
return cnvrtr.read(event, headers, body, data_unmarshaller) | ||
if cnvrtr.can_read(content_type): | ||
cnvrtr.event_supported(event) | ||
return cnvrtr.read(event, headers, body, data_unmarshaller) | ||
|
||
raise exceptions.UnsupportedEventConverter(content_type) | ||
|
||
def ToRequest(self, event: event_base.BaseEvent, | ||
converter_type: str, | ||
|
@@ -72,6 +82,9 @@ def ToRequest(self, event: event_base.BaseEvent, | |
:return: dict of HTTP headers and stream of HTTP request body | ||
:rtype: tuple | ||
""" | ||
if not isinstance(data_marshaller, typing.Callable): | ||
raise exceptions.InvalidDataMarshaller() | ||
|
||
if converter_type in self.__converters: | ||
cnvrtr = self.__converters.get(converter_type) | ||
return cnvrtr.write(event, data_marshaller) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Binary format was specified in v0.1 as well:
https://github.com/cloudevents/spec/blob/v0.1/http-transport-binding.md#31-binary-content-mode