Skip to content

Commit f4a3c05

Browse files
authored
Merge pull request #3 from cloudevents/sdk-spec
README update
2 parents 67e3525 + 8de0ade commit f4a3c05

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,23 @@ Package **cloudevents** provides primitives to work with CloudEvents specificati
66

77
Parsing upstream Event from HTTP Request:
88
```python
9+
import io
10+
911
from cloudevents.sdk.event import v02
1012
from cloudevents.sdk import marshaller
1113

12-
data = "<this is where your CloudEvent comes from>"
13-
m = marshaller.NewDefaultHTTPMarshaller(v02.Event)
14+
m = marshaller.NewDefaultHTTPMarshaller()
1415
event = m.FromRequest(
15-
{"Content-Type": "application/cloudevents+json"},
16-
data,
16+
v02.Event(),
17+
{
18+
"content-type": "application/cloudevents+json",
19+
"ce-specversion": "0.2",
20+
"ce-time": "2018-10-23T12:28:22.4579346Z",
21+
"ce-id": "96fb5f0b-001e-0108-6dfe-da6e2806f124",
22+
"ce-source": "<source-url>",
23+
"ce-type": "word.found.name",
24+
},
25+
io.BytesIO(b"this is where your CloudEvent data"),
1726
lambda x: x.read()
1827
)
1928

@@ -53,7 +62,7 @@ event = (
5362
)
5463
m = marshaller.NewHTTPMarshaller(
5564
[
56-
structured.NewJSONHTTPCloudEventConverter(type(event))
65+
structured.NewJSONHTTPCloudEventConverter()
5766
]
5867
)
5968

0 commit comments

Comments
 (0)