Add AddExtension::layer (#607)

This commit is contained in:
Jonas Platte 2021-12-10 22:56:56 +01:00 committed by GitHub
parent c8c0bb2ce1
commit b1623ce7f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -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)

View file

@ -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 }
}
}
@ -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>>,