Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Feature request: Handle Response Streaming in Event Handler #4476

@svozza

Description

@svozza

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

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

Labels

event-handlerThis item relates to the Event Handler Utilityfeature-requestThis item refers to a feature request for an existing or new utilityresearchingThis item is currently under consideration and we'll update once we have more info

Type

No type

Projects

Status

Working on it

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions