This guide shows you how to use the Functions Framework for local testing with:
- CloudEvents
- CloudEvents Conformance Testing
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 startYour function will be serving at http://localhost:8080/, however,
it is no longer accessible via HTTP GET requests from the browser.
cloudevents send http://localhost:8080 --specver--id abc-123 --source cloudevents.conformance.tool --type foo.bar