在使用函数URL时,如何查询HTTP请求头?

0

【以下的问题经过翻译处理】 当配置为使用Function URL时,我能在Lambda函数中查询HTTP请求头吗?如果可以,能否提供一个Python代码片段来实现?

profile picture
ESPECIALISTA
feita há 6 meses7 visualizações
1 Resposta
0

【以下的回答经过翻译处理】 HTTP 请求标头在“事件”对象中可用。例如,以下代码应返回请求浏览器的用户代理:

import json

def lambda_handler(event, context):
    return {
        'statusCode': 200,
        'body': json.dumps(event["headers"]["user-agent"])
    }
profile picture
ESPECIALISTA
respondido há 6 meses

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas