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!

posta 2 anni fa274 visualizzazioni
1 Risposta
1
Risposta accettata

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
con risposta 2 anni fa
profile pictureAWS
ESPERTO
verificato 2 anni 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