Query HTTP Request Headers When Using Function URLs?

0

Can I query HTTP request headers in a Lambda function when configured to use Function URL? If so, can you provide a Python snippet to do so? Thanks!

已提問 2 年前檢視次數 273 次
1 個回答
1
已接受的答案

The HTTP request headers are available within the event object. For example, the following code should return the requesting browser's user agent:

import json

def lambda_handler(event, context):
    return {
        'statusCode': 200,
        'body': json.dumps(event["headers"]["user-agent"])
    }
Ed
已回答 2 年前
profile pictureAWS
專家
已審閱 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南