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
66
77Parsing upstream Event from HTTP Request:
88``` python
9+ import io
10+
911from cloudevents.sdk.event import v02
1012from cloudevents.sdk import marshaller
1113
12- data = " <this is where your CloudEvent comes from>"
13- m = marshaller.NewDefaultHTTPMarshaller(v02.Event)
14+ m = marshaller.NewDefaultHTTPMarshaller()
1415event = 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)
5463m = marshaller.NewHTTPMarshaller(
5564 [
56- structured.NewJSONHTTPCloudEventConverter(type (event) )
65+ structured.NewJSONHTTPCloudEventConverter()
5766 ]
5867)
5968
You can’t perform that action at this time.
0 commit comments