Google Cloud Function中的通配符网址

时间:2018-10-22 17:35:18

标签: node.js express google-cloud-functions

您可以将Google Cloud Function定义为:

exports.functionName = (req, res) => {
  count++;

  // Note: the total function invocation count across
  // all instances may not be equal to this value!
  res.send(`Instance execution count: ${count}`);
};

我想知道您是否可以允许全部使用,例如接受以下任何参数:

https://us-central1-project-name.cloudfunctions.net/functionName/*/

目标是在GCF上托管一些动态生成的文件,目前我看不到允许某种通配符url的明显方法。

1 个答案:

答案 0 :(得分:1)

req对象是Express.js Request object,因此您可以像API文档所建议的那样使用它。 req.path会告诉您请求的路径,包括URL中函数名称之后的所有路径部分。因此,您可以解析它并使用其中的数据执行所需的操作。