Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnResponse #67

Closed
itsyoboieltr opened this issue Jul 19, 2023 · 4 comments
Closed

OnResponse #67

itsyoboieltr opened this issue Jul 19, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request feature request

Comments

@itsyoboieltr
Copy link

Is there a way to fire an event like with "onRequest", but with both the request and response objects? Basically, something like "onResponse".
I would like to log each response from the server. It would be nice for simple logging, something like: GET / 200 2ms

@SaltyAom
Copy link
Member

Yes, onAfterHandle as refers to this figure.

image

@itsyoboieltr
Copy link
Author

itsyoboieltr commented Jul 20, 2023

@SaltyAom Thank you! However, the onAfterHandle function only fires on successful responses. For instance, if the route is not found, or the body is invalid, or an error is thrown, it is not fired. How can I listen to both successful and non-successful requests? This is why I suggested onResponse.

Based on the drawing, I would suggest the following:
Untitled Diagram

@SaltyAom
Copy link
Member

SaltyAom commented Jul 20, 2023

Ok, this makes sense, I will add onResponse to Elysia 0.6.

Please leave this open until Elysia 0.6 stable is released.

@SaltyAom SaltyAom self-assigned this Jul 20, 2023
@SaltyAom SaltyAom added enhancement New feature or request feature request labels Jul 20, 2023
@SaltyAom
Copy link
Member

SaltyAom commented Aug 6, 2023

This is now introduced in Elysia 0.6, see onResponse

@SaltyAom SaltyAom closed this as completed Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature request
Projects
None yet
Development

No branches or pull requests

2 participants