File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -193,25 +193,26 @@ HTTP Headers, extracting the CloudEvents.
193
193
// some parts were removed //
194
194
195
195
const v1 = require (" cloudevents-sdk/v1" );
196
+
196
197
const receiver = new v1.StructuredHTTPReceiver ();
197
198
198
199
// some parts were removed //
199
200
200
- app .post (" /" , function (req , res ) {
201
- receiver .parse (req .body , req .headers )
202
- .then (myevent => {
201
+ app .post (" /" , (req , res ) => {
202
+ try {
203
+ let myevent = receiver .parse (req .body , req .headers )
204
+
205
+ // TODO use the event
203
206
204
- // TODO use the cloudevent
207
+ res . status ( 201 ). send ( " Event Accepted " );
205
208
206
- res .status (201 )
207
- .send (" Event Accepted" );
208
- })
209
- .catch (err => {
209
+ } catch (err) {
210
+ // TODO deal with errors
210
211
console .error (err);
211
212
res .status (415 )
212
213
.header (" Content-Type" , " application/json" )
213
214
.send (JSON .stringify (err));
214
- });
215
+ }
215
216
});
216
217
```
217
218
You can’t perform that action at this time.
0 commit comments