mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 17:57:47 +03:00
feat!: add telegram auth and async refactor
- Removed "/schedule/update-download-url" endpoint, this mechanism was replaced by Yandex Cloud FaaS. Ура :) - Improved schedule caching mechanism. - Added Telegram WebApp authentication support. - Reworked endpoints responses and errors mechanism. - Refactored application state management. - Make synchronous database operations, middlewares and extractors to asynchronous. - Made user password field optional to support multiple auth methods. - Renamed users table column "version" to "android_version" and made it nullable.
This commit is contained in:
@@ -57,18 +57,22 @@ pub trait FromRequestAsync: Sized {
|
||||
/// web::Json(user)
|
||||
/// }
|
||||
/// ```
|
||||
async fn from_request_async(req: HttpRequest, payload: Payload) -> Result<Self, Self::Error>;
|
||||
async fn from_request_async(
|
||||
req: &HttpRequest,
|
||||
payload: &mut Payload,
|
||||
) -> Result<Self, Self::Error>;
|
||||
}
|
||||
|
||||
impl<T: FromRequestAsync> FromRequest for AsyncExtractor<T> {
|
||||
type Error = T::Error;
|
||||
type Future = LocalBoxFuture<'static, Result<Self, Self::Error>>;
|
||||
|
||||
fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future {
|
||||
fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future {
|
||||
let req = req.clone();
|
||||
let payload = payload.take();
|
||||
let mut payload = Payload::None;
|
||||
|
||||
Box::pin(async move {
|
||||
T::from_request_async(req, payload)
|
||||
T::from_request_async(&req, &mut payload)
|
||||
.await
|
||||
.map(|res| Self(res))
|
||||
})
|
||||
@@ -82,6 +86,7 @@ pub struct SyncExtractor<T>(T);
|
||||
|
||||
impl<T> SyncExtractor<T> {
|
||||
/// Retrieving an object extracted with the extractor.
|
||||
#[allow(unused)]
|
||||
pub fn into_inner(self) -> T {
|
||||
self.0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user