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 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则