11.11.2.4. 标头
将 HTTP 请求标头返回为对象。
标头示例
export function handle(context: Context): string {
// log the incoming request body's 'hello' parameter
if (context.body) {
context.log.info((context.headers as Record<string, string>)['custom-header']);
} else {
context.log.info('No data received');
}
return 'OK';
}
您可以使用 curl 命令调用该函数:
示例命令
$ curl -H'x-custom-header: some-value’' http://example.function.com
输出示例
{"level":30,"time":1604511655265,"pid":3430203,"hostname":"localhost.localdomain","reqId":1,"msg":"some-value"}