|
2 | 2 |
|
3 | 3 | use std::marker::PhantomData; |
4 | 4 |
|
5 | | -use axum_core::{ |
6 | | - extract::{FromRequest, RequestParts}, |
7 | | - response::IntoResponse, |
8 | | -}; |
| 5 | +use axum_core::{extract::FromRequestParts, response::IntoResponse}; |
| 6 | +use http::request::Parts; |
9 | 7 | use sqlx::Transaction; |
10 | 8 |
|
11 | 9 | use crate::{ |
@@ -114,25 +112,23 @@ impl<DB: sqlx::Database, E> std::ops::DerefMut for Tx<DB, E> { |
114 | 112 | } |
115 | 113 | } |
116 | 114 |
|
117 | | -impl<DB: sqlx::Database, B, E> FromRequest<B> for Tx<DB, E> |
| 115 | +impl<DB: sqlx::Database, S, E> FromRequestParts<S> for Tx<DB, E> |
118 | 116 | where |
119 | | - B: Send, |
120 | 117 | E: From<Error> + IntoResponse, |
121 | 118 | { |
122 | 119 | type Rejection = E; |
123 | 120 |
|
124 | | - fn from_request<'req, 'ctx>( |
125 | | - req: &'req mut RequestParts<B>, |
| 121 | + fn from_request_parts<'req, 'state, 'ctx>( |
| 122 | + parts: &'req mut Parts, |
| 123 | + _state: &'state S, |
126 | 124 | ) -> futures_core::future::BoxFuture<'ctx, Result<Self, Self::Rejection>> |
127 | 125 | where |
128 | | - 'req: 'ctx, |
129 | 126 | Self: 'ctx, |
| 127 | + 'req: 'ctx, |
| 128 | + 'state: 'ctx, |
130 | 129 | { |
131 | 130 | Box::pin(async move { |
132 | | - let ext: &mut Lazy<DB> = req |
133 | | - .extensions_mut() |
134 | | - .get_mut() |
135 | | - .ok_or(Error::MissingExtension)?; |
| 131 | + let ext: &mut Lazy<DB> = parts.extensions.get_mut().ok_or(Error::MissingExtension)?; |
136 | 132 |
|
137 | 133 | let tx = ext.get_or_begin().await?; |
138 | 134 |
|
|
0 commit comments