functions icon indicating copy to clipboard operation
functions copied to clipboard

fix: allow returning `Response` objects from function Handlers

Open ndhoule opened this issue 1 year ago • 1 comments

Which problem is this pull request solving?

Per the functions documentation, it seems like you should be able to return a standard Response object from function handlers. However, the existing types only allows a user to return a HandlerResponse object.

List other issues or pull requests related to this problem

It looks like https://github.com/netlify/functions/pull/351 also addresses this issue, but that PR is a little stale at this point.

Describe the solution you've chosen

This updates the Handler type to accept both HandlerResponse and Response as a return value.

Checklist

Please add a x inside each checkbox:

  • [x] I have read the contribution guidelines.
  • [ ] The status checks are successful (continuous integration). Those can be seen below.

ndhoule avatar Jan 18 '24 22:01 ndhoule

Hey Nathan, appreciate the PR! The Handler type is for Lambda Compatibility Mode, which doesn't support Response. So the change you're proposing won't work.

Skn0tt avatar Jan 19 '24 08:01 Skn0tt