mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-31 00:00:10 +02:00
update examples
This commit is contained in:
@@ -46,7 +46,7 @@ async fn main() {
|
||||
.expect("can connect to database");
|
||||
|
||||
// build our application with some routes
|
||||
let app = Router::new()
|
||||
let app = Router::without_state()
|
||||
.route(
|
||||
"/",
|
||||
get(using_connection_pool_extractor).post(using_connection_extractor),
|
||||
@@ -77,13 +77,14 @@ async fn using_connection_pool_extractor(
|
||||
struct DatabaseConnection(sqlx::pool::PoolConnection<sqlx::Postgres>);
|
||||
|
||||
#[async_trait]
|
||||
impl<B> FromRequest<B> for DatabaseConnection
|
||||
impl<S, B> FromRequest<S, B> for DatabaseConnection
|
||||
where
|
||||
S: Send,
|
||||
B: Send,
|
||||
{
|
||||
type Rejection = (StatusCode, String);
|
||||
|
||||
async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection> {
|
||||
async fn from_request(req: &mut RequestParts<S, B>) -> Result<Self, Self::Rejection> {
|
||||
let Extension(pool) = Extension::<PgPool>::from_request(req)
|
||||
.await
|
||||
.map_err(internal_error)?;
|
||||
|
||||
Reference in New Issue
Block a user