generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 176
Open
0 / 10 of 1 issue completed
Copy link
Labels
confirmedThe scope is clear, ready for implementationThe scope is clear, ready for implementationevent-handlerThis item relates to the Event Handler UtilityThis item relates to the Event Handler Utilityfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utility
Description
Use case
Currently event handler only supports API Gateway Rest APIs. We should add support for HTTP APIs.
Solution/User Experience
The event source should be transparent to users, they should be able to define handlers that return any valid API Gateway response we support (JSON object, APIGatewayProxyEvent, APIGatewayProxyEventV2, Web Response object) and event handler will automatically detect the input event and convert to the appropriate response.
const app = new Router();
// this returns APIGatewayProxyEventV2
app.get('/test', () => ({
statusCode: 200,
body: JSON.stringify({ message: 'success' }),
headers: { 'content-type': 'application/json' },
cookies: ['cookie1', 'cookie2'],
}));
const v1Result = await app.resolve(aV1Event, context);
/**
v1Result = {
"statusCode": 200,
"headers": {
"content-type": "application/json",
},
"body": "{\"message\":\"success\"}",
"isBase64Encoded": false,
"multiValueHeaders": {
"set-cookie": [
"cookie1",
"cookie2"
]
}
}
*/
const v2Result = await app.resolve(aV2Event, context);
/**
v2Result = {
"statusCode": 200,
"headers": {
"content-type": "application/json",
},
"body": "{\"message\":\"success\"}",
"isBase64Encoded": false,
"cookies": [
"cookie1",
"cookie2"
]
}
**/
Alternative solutions
Alternative solution would be for customers to have specific resolvers for specific event sources:
const httpApiRouter = new HttpApiRouter()
// will only work with HttpApi eventsAcknowledgment
- This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Sub-issues
Metadata
Metadata
Assignees
Labels
confirmedThe scope is clear, ready for implementationThe scope is clear, ready for implementationevent-handlerThis item relates to the Event Handler UtilityThis item relates to the Event Handler Utilityfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utility
Type
Projects
Status
Working on it