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 のサンプルをご覧ください。