feat(set_header): refactor and improve multiple header middleware#672
Merged
jlizen merged 5 commits intotower-rs:mainfrom May 8, 2026
Conversation
Signed-off-by: Aminu Oluwaseun Joshua <[email protected]>
Signed-off-by: Aminu Oluwaseun Joshua <[email protected]>
Signed-off-by: Aminu Oluwaseun Joshua <[email protected]>
jlizen
requested changes
May 7, 2026
Member
jlizen
left a comment
There was a problem hiding this comment.
I like the intent here, but there are a few issues as written, see below.
Signed-off-by: Aminu Oluwaseun Joshua <[email protected]>
jlizen
requested changes
May 8, 2026
|
|
||
| impl<T, M> From<(HeaderName, M)> for HeaderMetadata<T> | ||
| where | ||
| M: CloneableMakeHeaderValue<T> + Clone + 'static, |
Member
There was a problem hiding this comment.
We should do this based on the public traits instead:
impl<T, M> From<(HeaderName, M)> for HeaderMetadata<T>
where
M: MakeHeaderValue<T> + Clone + Send + Sync + 'static,
{
fn from((header_name, make): (HeaderName, M)) -> Self {
HeaderMetadata::new(header_name, make)
}
}
Signed-off-by: Aminu Oluwaseun Joshua <[email protected]>
jlizen
approved these changes
May 8, 2026
Member
jlizen
left a comment
There was a problem hiding this comment.
Great stuff! Thanks for the contribution. Will get a release out.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Fixes #571
Offering the ability to add multiple headers at once
Solution
For better code organisation, the
response.rsfile, which handles the response request, is now a module and split into two files. One for setting a single header and the other for multiple, while still maintaining the current API structure.The functions handling setting headers take a dynamic variable that implements
HeaderMetadataGenerator. The newly createdHeaderMetadataand tuple of(HeaderName, M)currently implemented inMcan beHeaderValue(A test case covers this). This also helps with maintainability