在 HTTP 响应之后执行

发送 HTTP 响应后不会执行的代码示例。

代码示例

Node.js

如需向 Cloud Functions 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证

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.
 */
functions.http('afterResponse', (req, res) => {
  res.end();

  // This statement may not execute
  console.log('Function complete!');
});

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅 Google Cloud 示例浏览器