小编Chr*_*ouw的帖子

将自定义参数/查询/标头添加到 Google Cloud 函数

我基本上想知道我是否可以让 https Google Cloud 函数根据我作为参数传递给它的内容以不同的方式执行(就像任何带参数的普通函数一样)。可能使用 URL 内的简单查询或任何其他有效的方法。

例如,看一下任何教程中的基本启动函数:

exports.helloWorld = functions.https.onRequest((req, res) => {
  res.status(200).send('Hello, World!');
});
Run Code Online (Sandbox Code Playgroud)

我想做这样的事情:

exports.helloWorld = functions.https.onRequest((req, res) => {
  let name = req.query;
  res.status(200).send(`Hello, ${name}!`);
});
Run Code Online (Sandbox Code Playgroud)

我希望这是有道理的。任何帮助,将不胜感激。

javascript node.js google-cloud-platform google-cloud-functions

2
推荐指数
1
解决办法
3997
查看次数