Although it is possible to add premiddleware to intercept the request before it is processed by foal's core.
It is better to simply pass the raw express response object to Context as well.
So developers can interact with the raw response object in advanced use case while hooks for checking incoming request can still be reusable when implementing features like SSE(server-sent event) or streaming.
A simple check of the response type in sendResponse function to determine whether or not to execute the default behaviours would be fine.
@LoicPoullain What do you think? I can submit a PR for this feature.
Although it is possible to add premiddleware to intercept the request before it is processed by foal's core. It is better to simply pass the raw express response object to Context as well. So developers can interact with the raw response object in advanced use case while hooks for checking incoming request can still be reusable when implementing features like SSE(server-sent event) or streaming. A simple check of the response type in sendResponse function to determine whether or not to execute the default behaviours would be fine.
@LoicPoullain What do you think? I can submit a PR for this feature.