withastro / roadmap

Ideas, suggestions, and formal RFC proposals for the Astro project.
292 stars 29 forks source link

RFC: throwable response #363

Closed xstevenyung closed 1 year ago

xstevenyung commented 1 year ago

Summary

Allows to stop execution of an endpoint or accessing a page with Astro SSR in nested functions by utilizing similar API to Remix with throw Response.

Links

matthewp commented 1 year ago

The obstacle here is that with streaming the response is already sent out after the page component's frontmatter runs. If you were to throw in a component inside of the page component it would be too late. I'm not sure how we can address this problem.

xstevenyung commented 1 year ago

I'm not familiar with the whole streaming response flow, but I guess it make sense.

I saw a bunch of middleware RFCs and discussion going on. A middleware system will kind of solve this issue in a way, so I'll close this RFC for now.

Thanks for your feedback, I will dig for alternative solution 🙏

Cheers