File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,23 @@ Package **cloudevents** provides primitives to work with CloudEvents specificati
6
6
7
7
Parsing upstream Event from HTTP Request:
8
8
``` python
9
+ import io
10
+
9
11
from cloudevents.sdk.event import v02
10
12
from cloudevents.sdk import marshaller
11
13
12
- data = " <this is where your CloudEvent comes from>"
13
- m = marshaller.NewDefaultHTTPMarshaller(v02.Event)
14
+ m = marshaller.NewDefaultHTTPMarshaller()
14
15
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" ),
17
26
lambda x : x.read()
18
27
)
19
28
@@ -53,7 +62,7 @@ event = (
53
62
)
54
63
m = marshaller.NewHTTPMarshaller(
55
64
[
56
- structured.NewJSONHTTPCloudEventConverter(type (event) )
65
+ structured.NewJSONHTTPCloudEventConverter()
57
66
]
58
67
)
59
68
You can’t perform that action at this time.
0 commit comments