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

0

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

profile picture
ESPERTO
posta 6 mesi fa7 visualizzazioni
1 Risposta
0

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

import json

def lambda_handler(event, context):
    return {
        'statusCode': 200,
        'body': json.dumps(event["headers"]["user-agent"])
    }
profile picture
ESPERTO
con risposta 6 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande