AWS API Gateway-如何在正文映射模板中获取日期/时间戳/纪元? [英] AWS API Gateway - How do I get the date/timestamp/epoch in a body mapping template?

查看:145
本文介绍了AWS API Gateway-如何在正文映射模板中获取日期/时间戳/纪元?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在主体映射模板中包含API网关方法的请求时间.是否有日期/时间变量或函数?我在模板参考.

I need to include the request time in the body mapping template for an API Gateway method. Is there a date/time variable or function? I couldn't find anything in the template reference.

示例人体贴图模板:

Action=SendMessage&MessageBody=$util.urlEncode("{""timestamp"":""TIMESTAMP_HERE"",""body-json"":$input.json('$'),""params"":""$input.params()""}")

推荐答案

更新: API网关刚刚添加了两个新的上下文变量 http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html

UPDATE: API Gateway just added two new context variables http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html

$context.requestTime    The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm).
$context.requestTimeEpoch   The Epoch-formatted request time.

API网关当前不支持此功能.之前在论坛上已要求使用它- https://forums.aws.amazon.com/thread.jspa?messageID=697658& .我们的积压订单中有此功能,但是很遗憾,我无法遵守任何时间表.

API gateway doesn't support this currently. Its been requested before on the forums - https://forums.aws.amazon.com/thread.jspa?messageID=697658&. We have this feature in our backlog, but unfortunately I can't commit to any timelines.

这篇关于AWS API Gateway-如何在正文映射模板中获取日期/时间戳/纪元?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆