Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 1.11 KB

cloudevents.md

File metadata and controls

46 lines (35 loc) · 1.11 KB

CloudEvents

This guide shows you how to use the Functions Framework for local testing with:

Local Testing of CloudEvents

In your package.json, specify --signature-type=cloudevent" for the functions-framework:

{
  "scripts": {
    "start": "functions-framework --target=helloCloudEvents --signature-type=cloudevent"
  }
}

Create an index.js file:

exports.helloCloudEvents = (cloudevent) => {
  console.log(cloudevent.specversion);
  console.log(cloudevent.type);
  console.log(cloudevent.source);
  console.log(cloudevent.subject);
  console.log(cloudevent.id);
  console.log(cloudevent.time);
  console.log(cloudevent.datacontenttype);
}

Start the Functions Framework:

npm start

Your function will be serving at http://localhost:8080/, however, it is no longer accessible via HTTP GET requests from the browser.

Create and send a cloudevent to the function

cloudevents send http://localhost:8080 --specver--id abc-123 --source cloudevents.conformance.tool --type foo.bar