Skip to content

feat: add event-based response state #14

Closed
@francescovallone

Description

As a developer I want to access the current state of the response inside the Middleware to execute code after the execution of the handler if needed.

The InternalResponse class should expose a on method that will require the event to subscribe and the listener function.

The events can be:

  • beforeSend. Event triggered before the response has sent the data
  • data. Event triggered when the data has been sent.
  • afterSend. Event triggered when the data has been sent but the response has not been closed.
  • close. Event triggered when the response and the connection has been closed.
  • redirect. Event triggered when the handler is redirecting to a new path.
  • error. Event triggered when an error has been thrown.
  • all. Wildcard for all the events.

The listener should accept a parameter that is the event which triggered it.

The stream should be broadcast to ensure that more listener can listen to the same event.

Metadata

Labels

enhancementNew feature or request

Projects

  • Status

    Closed

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions