Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce serialzeBodyToJson property on HTTP event files #7836

Open
basvandriel opened this issue Jan 15, 2025 · 1 comment
Open

Introduce serialzeBodyToJson property on HTTP event files #7836

basvandriel opened this issue Jan 15, 2025 · 1 comment
Labels
stage/needs-feedback Needs feedback from the community (are you also interested in/experiencing this?) type/feature Feature request

Comments

@basvandriel
Copy link

Describe your idea/feature/enhancement

Normally, when configuring an FunctionUrl for a Lambda function, you would invoke it like below.

sam local invoke SomeFunction --event some-event.json

Where the event file includes a HTTP payload, containing a raw JSON string for the body.

{
    "version": "2.0",
    "routeKey": "$default",
    "rawPath": "/somepath",
    "rawQueryString": "",
    "headers": {
        "Content-Type": "application/json"
    },
    "requestContext": {
        "http": {
            "method": "POST",
            "path": "/",
            "protocol": "HTTP/1.1"
        },
        "routeKey": "$default",
        "stage": "$default"
    },
    "body": "{\"message\": \"hi\"}",
    "isBase64Encoded": false
}

When the application grows, I would like the application be easier to test locally. Including JSON objects in the body to send data, with a flag to turn this off or on would therefor be valueable.

Proposal

Introduce an optional serialzeBodyToJson property on the object and default it to false. When true, it will directly send the body to the lambda function as a dictionary.

@basvandriel basvandriel added stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. type/feature Feature request labels Jan 15, 2025
@roger-zhangg
Copy link
Member

Hi basvandriel,

Thanks for reaching out, could you help to elaborate more on what the Proposed UX might look like?

@roger-zhangg roger-zhangg added stage/needs-feedback Needs feedback from the community (are you also interested in/experiencing this?) and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/needs-feedback Needs feedback from the community (are you also interested in/experiencing this?) type/feature Feature request
Projects
None yet
Development

No branches or pull requests

2 participants