Skip to content

Commit

Permalink
Add AddExtension::layer (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte authored Dec 10, 2021
1 parent c8c0bb2 commit b1623ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion axum/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

# Unreleased

- None.
- **added:** `axum::AddExtension::layer` ([#607])

[#607]: https://github.com/tokio-rs/axum/pull/607

# 0.4.2 (06. December, 2021)

Expand Down
9 changes: 8 additions & 1 deletion axum/src/add_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct AddExtensionLayer<T> {
impl<T> AddExtensionLayer<T> {
/// Create a new [`AddExtensionLayer`].
pub fn new(value: T) -> Self {
AddExtensionLayer { value }
Self { value }
}
}

Expand Down Expand Up @@ -49,6 +49,13 @@ pub struct AddExtension<S, T> {
value: T,
}

impl<S, T> AddExtension<S, T> {
/// Create a new [`AddExtensionLayer`].
pub fn layer(value: T) -> AddExtensionLayer<T> {
AddExtensionLayer::new(value)
}
}

impl<ResBody, S, T> Service<Request<ResBody>> for AddExtension<S, T>
where
S: Service<Request<ResBody>>,
Expand Down

0 comments on commit b1623ce

Please sign in to comment.