AWS API Gateway:传递引荐来源网址
对API网关的请求是否有可能将引荐来源网址传递给Lambda?例如,我很想让我的lambda函数知道请求是否来自域名"good.com"和"bad.com".
Is it possible for requests to the API-Gateway to pass the referrer URL to Lambda? For example, I'd love to let my lambda functions know if a request comes from the domain "good.com" vs. "bad.com".
我熟悉受支持的$ context变量,我知道其中没有引荐来源网址.我想知道是否还有另一种方式.如果有可能,我需要采取什么步骤?
I'm familiar with the list of supported $context Variables and I know a referrer url is not in there. I'm wondering if there is another way. If it is possible, what steps do I need to take?
此处是操作方法.
-
事实证明,该映射模板允许您映射 HTTP标头 ,而不仅仅是支持的变量列表在文档中.
包含引荐来源网址域的HTTP标头称为来源".包含引用页面URL的标题称为引用".
The HTTP header that contains the referrer domain is called "Origin". The header that contains the referer page URL is called "Referer".
因此,例如,您可以将其放在映射模板中,它将获取关联的标头信息:
So, for example, you can put this in your mapping template and it will grab the associated header information:
{
"origin" : "$input.params('origin')",
"referer" : "$input.params('referer')"
}
Origin抓取example.com.引荐来源抓住example.com/pagename
Origin grabs example.com. Referer grabs example.com/pagename