You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/event-handler/rest.md
+23-3Lines changed: 23 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -515,11 +515,31 @@ We plan to add first-class support for binary responses in a future release. Ple
515
515
516
516
### Response streaming
517
517
518
-
!!! note "Coming soon"
518
+
!!! note "Compatibility"
519
+
Response streaming is only available for [API Gateway REST APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/response-transfer-mode.html)
520
+
and [Lambda function URLs](https://docs.aws.amazon.com/lambda/latest/dg/configuration-response-streaming.html).
521
+
522
+
You can send responses to the client using HTTP streaming by wrapping your router with the `streamify` function to turn all the associated route handlers into stream compatible handlers. This is useful when you need to send large payloads or want to start sending data before the entire response is ready.
523
+
524
+
In order to gain the most benefit, you should return either a readable [Nodejs stream](https://nodejs.org/api/stream.html#readable-streams),
525
+
a duplex [Nodejs stream](https://nodejs.org/api/stream.html#class-streamduplex), or
526
+
a [Web stream](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API#browser_compatibility) from your handlers. However, you can also return
527
+
other types and these will also be delivered via HTTP streaming.
At the moment, Event Handler does not support streaming responses. This means that the entire response must be generated and returned by the route handler before it can be sent to the client.
538
+
- Returning large payloads (> 6MB)
539
+
- Processing data that can be sent incrementally
540
+
- Reducing time-to-first-byte for long-running operations is a requirement
521
541
522
-
Please [check this issue](https://github.com/aws-powertools/powertools-lambda-typescript/issues/4476) for more details and add 👍 if you would like us to prioritize it.
542
+
For most use cases, the standard `resolve` method is sufficient.
0 commit comments