[英]How to detect HTTP user agent of GET request on Amazon API Gateway?
我在Amazon API Gateway上創建HTTP GET請求方法。 現在,我想從HTTP GET請求中檢測客戶端IP地址和HTTP_USER_AGENT,並將它們傳遞到標頭中的我的自定義項目。
以下是我在AWS api網關上為http GET請求定義的映射模板
以下是我的http請求網址
https://Yxz5Vp6.execute-api.us-west-2.amazonaws.com/alpha/post/share?auth=25142452&id=23365242
並請求我在標題中收到的響應
array (
'x-amzn-apigateway-api-id' =>
array (
0 => 'yv9frefnud',
),
'x-amzn-trace-id' =>
array (
0 => 'Root=1-5c247572-db8d0dc0c5aaa725bf7ad089',
),
'user-agent' =>
array (
0 => 'AmazonAPIGateway_yv9frefnud',
),
'content-type' =>
array (
0 => 'application/json',
),
'accept' =>
array (
0 => 'application/json',
),
'host' =>
array (
0 => 'fayvo-post.us-west-2.elasticbeanstalk.com',
),
'connection' =>
array (
0 => 'Keep-Alive',
),
)
您將要創建一個API網關映射模板 。 定義一個看起來像這樣的地圖:
{
"caller_ip" : "$input.params('X-Forwarded-For')",
"useragent" : "$context.identity.userAgent"
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.