h3 icon indicating copy to clipboard operation
h3 copied to clipboard

Support for onAfterResponse hook (inside event handlers)

Open frenzzy opened this issue 1 year ago • 0 comments

Describe the feature

Hello, currently, the onBeforeResponse middleware hook is available for use, but onAfterResponse is only supported at the createApp level.

Is it possible to implement onAfterResponse in a manner similar to onBeforeResponse?

The challenge is that higher-level libraries, such as vinxi, do not utilize createApp internally. Consequently, the only way to execute custom code after a response is through the onBeforeResponse middleware. However, H3 does not export its handleHandlerResponse function, which would allow for easy waiting on any type of response to finish, thereby emulating the timing of onAfterResponse.

As an alternative, could H3 export the handleHandlerResponse as an asynchronous function? This would enable the implementation of onAfterResponse timing in userland without the need to copy-paste its source code.

What are your thoughts?

Additional information

  • [ ] Would you be willing to help implement this feature?

frenzzy avatar Feb 07 '24 12:02 frenzzy