Skip to content

Commit

Permalink
chore(functions/concepts): Migrate afterResponse sample to gen2
Browse files Browse the repository at this point in the history
  • Loading branch information
ddegraf authored and Ace Nassri committed Jan 13, 2023
1 parent aa8f79b commit 11a4b46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions functions/concepts/afterResponse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
'use strict';

// [START functions_concepts_after_response]
const functions = require('@google-cloud/functions-framework');

/**
* HTTP Cloud Function that may not completely
* execute due to early HTTP response
*
* @param {Object} req Cloud Function request context.
* @param {Object} res Cloud Function response context.
*/
exports.afterResponse = (req, res) => {
functions.http('afterResponse', (req, res) => {
res.end();

// This statement may not execute
console.log('Function complete!');
};
});
// [END functions_concepts_after_response]
3 changes: 3 additions & 0 deletions functions/concepts/afterResponse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
},
"engines": {
"node": ">=12.0.0"
},
"dependencies": {
"@google-cloud/functions-framework": "^3.1.3"
}
}

0 comments on commit 11a4b46

Please sign in to comment.