Google Cloud Run functions (Node.js) JavaScript
一个用于 Google Cloud Run functions (Node.js) 的 JavaScript 代码片段,以空 GIF 响应对 /pixel.gif 的请求,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)