start fixing tests in plume-models

This commit is contained in:
Igor Galić 2020-01-27 20:45:24 +01:00
parent 59e5c49aa8
commit b51551973a
No known key found for this signature in database
GPG Key ID: ACFEFF7F6A123A86

View File

@ -48,7 +48,7 @@ mod module {
mod module { mod module {
use crate::{db_conn::DbConn, search, users}; use crate::{db_conn::DbConn, search, users};
use rocket::{ use rocket::{
request::{self, FromRequest, Request}, request::{self, FromRequestAsync, Request},
Outcome, State, Outcome, State,
}; };
use scheduled_thread_pool::ScheduledThreadPool; use scheduled_thread_pool::ScheduledThreadPool;
@ -62,20 +62,22 @@ mod module {
pub worker: Arc<ScheduledThreadPool>, pub worker: Arc<ScheduledThreadPool>,
} }
impl<'a, 'r> FromRequest<'a, 'r> for PlumeRocket { impl<'a, 'r> FromRequestAsync<'a, 'r> for PlumeRocket {
type Error = (); type Error = ();
fn from_request(request: &'a Request<'r>) -> request::Outcome<PlumeRocket, ()> { fn from_request(request: &'a Request<'r>) -> request::FromRequestFuture<'a, Self, Self::Error> {
let conn = DbConn::from_request(request).await; Box::pin(async move {
let user = request.guard::<users::User>().succeeded(); let conn = try_outcome!(DbConn::from_request(request).await);
let worker = request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>()?; let user = try_outcome!(users::User::from_request(request).await);
let searcher = request.guard::<'_, State<'_, Arc<search::Searcher>>>()?; let worker = try_outcome!(request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>());
let searcher = try_outcome!(request.guard::<'_, State<'_, Arc<search::Searcher>>>());
Outcome::Success(PlumeRocket { Outcome::Success(PlumeRocket {
conn, conn,
user, user: Some(user),
worker: worker.clone(), worker: worker.clone(),
searcher: searcher.clone(), searcher: searcher.clone(),
}) })
})
} }
} }
} }