Google Cloud Run functions (Node.js) JavaScript
/pixel.gif へのリクエストに空の GIF を返す、Google Cloud Run functions (Node.js) 用の JavaScript スニペット。GIF は起動時に一度だけデコードします。
Google Cloud Run functions (Node.js) JavaScript
import * as functions from '@google-cloud/functions-framework';
const GIF = Buffer.from('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', 'base64');
functions.http('pixel', (req, res) => {
if (req.path !== '/pixel.gif') {
res.sendStatus(404);
return;
}
res.set('Cache-Control', 'no-store').type('gif').send(GIF);
});
このスニペットは実行し、返されたバイト列を照合しました。
確認
curl -sI http://localhost:8080/pixel.gif
公式サイト: Google Cloud Run functions (Node.js)