ביצוע אחרי תגובת HTTP

דוגמה לקוד שלא יופעל אחרי שליחת תשובת HTTP.

דוגמת קוד

Node.js

כדי לבצע אימות לפונקציות של Cloud Run, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

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 .