Backport impl tower::Layer for Extension (#805)

* Implement `tower::Layer` for `Extension` (#801)

* Implement `tower::Layer` for `Extension`

* changelog

* Deprecate `AddExtensionLayer`

* changelog

* Add missing #[allow(deprecated)]
This commit is contained in:
David Pedersen
2022-03-01 12:05:42 +01:00
committed by GitHub
parent 5cb6e6d16e
commit ee387ae30b
16 changed files with 67 additions and 43 deletions
+2 -2
View File
@@ -29,7 +29,7 @@ use std::{
time::Duration,
};
use tower::{BoxError, ServiceBuilder};
use tower_http::{add_extension::AddExtensionLayer, trace::TraceLayer};
use tower_http::trace::TraceLayer;
use uuid::Uuid;
#[tokio::main]
@@ -61,7 +61,7 @@ async fn main() {
}))
.timeout(Duration::from_secs(10))
.layer(TraceLayer::new_for_http())
.layer(AddExtensionLayer::new(db))
.layer(Extension(db))
.into_inner(),
);