Feature request: Handle Response Streaming in Event Handler
Closed this issue · 2 comments
Use case
For Lambda function URLs it is possible to stream response payloads back to the client. While Event Handler does not currently support Lambda function URLs, we will in the future.
We need to investigate how this mode of response impacts the API we plan to launch at GA.
Solution/User Experience
We want an experience with as little friction as possible but there are a lot of unknowns here so this is by no means the definitive DX:
import { Router } from '@aws-lambda-powertools/event-handler/experimental-rest';
import type { Context } from 'aws-lambda';
const app = new Router({streaming: true});
app.get('/stream', async () => {
const myStream = createWriteStream()
myStream.write("Hello ");
myStream.write("world ");
myStream.write("from ");
myStream.write("Lambda!");
myStream.end();
return myStream;
});
export const handler = async (event: unknown, context: Context) => {
return app.resolve(event, context);
};Alternative solutions
Acknowledgment
- 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.
Warning
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
This is now released under v2.28.0 version!