2
我正在尝试为Amazon SNS设置Webhook。 SNS将发送一个JSON对象给webhook。基于KRL文档,我可以使用event:param('name')来获取事件参数。这适用于表单编码数据,但是JSON呢?KRL webhooks接收JSON
我发出了呼吁postbin.org,这是postbin报道什么:
body {
"Message": "You have ...",
"MessageId": "958....",
"Signature": "vo3v5f....",
...
}
这里是我想什么KRL写:
rule sns_webhook {
select when webhook sometopic Type "SubscriptionConfirmation"
pre {
topic_arn = event:param("TopicARN");
signature = event:param("Signature");
message = event:param("Message");
subscribe_url = event:param("SubscribeURL");
}
if valid_signature(signature) then {
confirm_subscription(subscribe_url);
}
}
这会为HTTP可能工作形式编码的数据,但与JSON我期望以下将需要:
rule sns_json {
select when webhook sometopic
pre {
body = event:param('body').decode();
msg_type = body.pick("Type");
signature = body.pick("Signature");
...
}
if msg_type eq "SubscriptionConfirmation" && valid(signature) then
{
confirm_subscription(...);
}
}
我是否需要使用秒这里介绍的ond方法?请问event:param('body')从SNS消息中获取JSON数据?