-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add extensions, refactor context and request-related #47
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ommon `Request`.
Desiders
added
A-telers
Area: telers
A-telers-macros
Area: telers-macros
breaking change
A PR that makes a breaking change.
P-high
High priority
labels
Dec 25, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-telers
Area: telers
A-telers-macros
Area: telers-macros
breaking change
A PR that makes a breaking change.
P-high
High priority
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add
Extension
as inaxum
to save data without key, just by type. It's more convenient an analogue of the context because it can be extracted without implementations ofExtractor
.Example of usage and registration: https://github.com/Desiders/telers/blob/dev-1.x/examples/extractor/src/main.rs#L130, https://github.com/Desiders/telers/blob/dev-1.x/examples/extractor/src/main.rs#L145.
Refactor
Context
to be easier to use: now you shouldn't to wrap any value toBox
atinsert
, it's wrapped by the library. Typecast in user side removed, all methods likeget
already does it.Don't forget to change all
insert
calls to removeBox
because otherwise typecast fail (it will be saved asBox<Box<...>>
).Code example:
Request
in middlewares and filters.Now all data like context and extractors will be passed in request for filters and middlewares instead of pass them in different arguments:
New filter:
Old filter:
As you can see, there also added
&mut
, so you can without any problems change the request (there noArc
now)FromEventAndContext
toExtractor
andHandlerObject
toHandlerComposition
1.71.1
telers::{router/...}::Request
totelers::Request