From 8de0ade014ca4b67cc4ca6273160ee595ea3ff2e Mon Sep 17 00:00:00 2001 From: Denis Makogon Date: Sat, 8 Dec 2018 18:03:14 -0500 Subject: [PATCH] README update Signed-off-by: Denis Makogon --- README.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index dcc11a8c..82e707de 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,23 @@ Package **cloudevents** provides primitives to work with CloudEvents specificati Parsing upstream Event from HTTP Request: ```python +import io + from cloudevents.sdk.event import v02 from cloudevents.sdk import marshaller -data = "" -m = marshaller.NewDefaultHTTPMarshaller(v02.Event) +m = marshaller.NewDefaultHTTPMarshaller() event = m.FromRequest( - {"Content-Type": "application/cloudevents+json"}, - data, + v02.Event(), + { + "content-type": "application/cloudevents+json", + "ce-specversion": "0.2", + "ce-time": "2018-10-23T12:28:22.4579346Z", + "ce-id": "96fb5f0b-001e-0108-6dfe-da6e2806f124", + "ce-source": "", + "ce-type": "word.found.name", + }, + io.BytesIO(b"this is where your CloudEvent data"), lambda x: x.read() ) @@ -53,7 +62,7 @@ event = ( ) m = marshaller.NewHTTPMarshaller( [ - structured.NewJSONHTTPCloudEventConverter(type(event)) + structured.NewJSONHTTPCloudEventConverter() ] )