11.11.2.2. query
返回请求的查询字符串(如果有),作为键值对。这些属性也可在上下文对象本身中找到。
查询示例
export function handle(context: Context): string {
// log the 'name' query parameter
if (context.query) {
context.log.info((context.query as Record<string, string>).name);
} else {
context.log.info('No data received');
}
return 'OK';
}
您可以使用 kn func invoke 命令访问功能:
示例命令
$ kn func invoke --target 'http://example.function.com' --data '{"name": "tiger"}'
输出示例
{"level":30,"time":1604511655265,"pid":3430203,"hostname":"localhost.localdomain","reqId":1,"msg":"tiger"}
{"level":30,"time":1604511655265,"pid":3430203,"hostname":"localhost.localdomain","reqId":1,"msg":"tiger"}