Skip to content

Instantly share code, notes, and snippets.

@gyfis
Last active January 18, 2019 10:48
Show Gist options
  • Save gyfis/eb4f8bde54d9ad43ec865be1359bfb87 to your computer and use it in GitHub Desktop.
Save gyfis/eb4f8bde54d9ad43ec865be1359bfb87 to your computer and use it in GitHub Desktop.
Path parameters inconsistency - SAM
// hello_world/api.js
exports.lambdaHandler = async (event, context) => {
return {
'statusCode': 200,
'body': JSON.stringify(event)
}
};
// 127.0.0.1:3000/test/users/3/file/Desktop%2Fphotos%2Fcat.png
// output -> local_response.json
// <AWS-API-GATEWAY-URL>/test/users/3/file/Desktop%2Fphotos%2Fcat.png
// output -> aws_response.json
{
"resource": "/{path+}",
"path": "/test/users/3/file/Desktop%2Fphotos%2Fcat.png",
"httpMethod": "GET",
"headers": {
"values": "<FILTERED>"
},
"queryStringParameters": null,
"pathParameters": {
"path": "test/users/3/file/Desktop%2Fphotos%2Fcat.png"
},
"stageVariables": null,
"requestContext": {
"value": "<FILTERED>"
},
"body": null,
"isBase64Encoded": false
}
{
"resource": "/{path+}",
"path": "/test/users/3/file/Desktop/photos/cat.png",
"httpMethod": "GET",
"headers": {
"values": "<FILTERED>"
},
"queryStringParameters": null,
"pathParameters": {
"path": "test/users/3/file/Desktop/photos/cat.png"
},
"stageVariables": null,
"requestContext": {
"value": "<FILTERED>"
},
"body": null,
"isBase64Encoded": false
}
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Path parameters example
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello_world/
Handler: app.lambdaHandler
Runtime: nodejs8.10
Events:
HelloWorld:
Type: Api
Properties:
Path: /{path+}
Method: get
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment