mirror of https://github.com/knative/func.git
fix: return JSON in Node.js event template (#211)
The event template was just returning a string, but the default response content type is application/json so browsers were failing to parse the string as JSON. Signed-off-by: Lance Ball <lball@redhat.com>
This commit is contained in:
parent
470ebb9da4
commit
beb838ff43
|
@ -19,13 +19,15 @@ const { CloudEvent, HTTP } = require('cloudevents');
|
|||
*
|
||||
* const incomingEvent = context.cloudevent;
|
||||
*
|
||||
* @param {Context} context the invocation context
|
||||
* @param {Object} user the CloudEvent data. If the data content type is application/json
|
||||
* this will be converted to an Object via JSON.parse()
|
||||
* @param {Context} context the invocation context
|
||||
*/
|
||||
function verifyUser(context, user) {
|
||||
if (!context.cloudevent) {
|
||||
return 'No cloud event received';
|
||||
return {
|
||||
message: 'No cloud event received'
|
||||
};
|
||||
}
|
||||
|
||||
context.log.info('Processing user', user);
|
||||
|
|
Loading…
Reference in New Issue