mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-13 00:00:35 +02:00
Implement tower::Layer for Extension (#801)
* Implement `tower::Layer` for `Extension` * changelog
This commit is contained in:
@@ -18,7 +18,7 @@ use axum::{
|
||||
extract::{Extension, FromRequest, RequestParts},
|
||||
http::StatusCode,
|
||||
routing::get,
|
||||
AddExtensionLayer, Router,
|
||||
Router,
|
||||
};
|
||||
use sqlx::postgres::{PgPool, PgPoolOptions};
|
||||
|
||||
@@ -49,7 +49,7 @@ async fn main() {
|
||||
"/",
|
||||
get(using_connection_pool_extractor).post(using_connection_extractor),
|
||||
)
|
||||
.layer(AddExtensionLayer::new(pool));
|
||||
.layer(Extension(pool));
|
||||
|
||||
// run it with hyper
|
||||
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
|
||||
|
||||
Reference in New Issue
Block a user