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

feat: add middlewares for handler #105

Merged
merged 3 commits into from
Sep 16, 2024
Merged

feat: add middlewares for handler #105

merged 3 commits into from
Sep 16, 2024

Conversation

TBXark
Copy link
Contributor

@TBXark TBXark commented Aug 16, 2024

Sometimes it is necessary to add middleware for individual handlers.

I added an example in the example, for instance, sometimes when we handle CallbackQuery, it may not be so quick, and users may click the button multiple times, resulting in multiple requests arriving simultaneously. At this point, we can use singleFlight to ensure that only one request is processed.

@TBXark
Copy link
Contributor Author

TBXark commented Aug 16, 2024

The addition of m ...Middleware to the RegisterHandlerXXX function signature will not affect the execution of the previous code, because m is a variadic parameter with a default value of empty, so the previous code will not be impacted.

@TBXark TBXark changed the title feat: each handler can add middleware. feat: add middleware for handler Aug 16, 2024
@TBXark TBXark changed the title feat: add middleware for handler feat: add middlewares for handler Aug 16, 2024
@negasus negasus merged commit db32473 into go-telegram:main Sep 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants