2019-03-09 18:49:11 +01:00
|
|
|
use std::cell::RefCell;
|
|
|
|
use std::rc::Rc;
|
2021-01-11 02:29:16 +01:00
|
|
|
use std::task::Poll;
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2019-05-05 04:43:49 +02:00
|
|
|
use actix_http::{Extensions, Request, Response};
|
2021-01-06 12:35:30 +01:00
|
|
|
use actix_router::{Path, ResourceDef, Router, Url};
|
2019-11-26 06:25:50 +01:00
|
|
|
use actix_service::boxed::{self, BoxService, BoxServiceFactory};
|
2019-12-08 14:25:24 +01:00
|
|
|
use actix_service::{fn_service, Service, ServiceFactory};
|
2021-01-06 12:35:30 +01:00
|
|
|
use futures_core::future::LocalBoxFuture;
|
|
|
|
use futures_util::future::join_all;
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2019-04-15 16:32:49 +02:00
|
|
|
use crate::config::{AppConfig, AppService};
|
2021-01-16 00:37:33 +01:00
|
|
|
use crate::data::FnDataFactory;
|
2019-03-11 00:35:38 +01:00
|
|
|
use crate::error::Error;
|
2019-03-09 18:49:11 +01:00
|
|
|
use crate::guard::Guard;
|
2019-04-08 08:06:21 +02:00
|
|
|
use crate::request::{HttpRequest, HttpRequestPool};
|
2019-03-09 18:49:11 +01:00
|
|
|
use crate::rmap::ResourceMap;
|
2019-11-20 18:33:22 +01:00
|
|
|
use crate::service::{AppServiceFactory, ServiceRequest, ServiceResponse};
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2019-07-17 11:48:37 +02:00
|
|
|
type Guards = Vec<Box<dyn Guard>>;
|
2019-11-26 06:25:50 +01:00
|
|
|
type HttpService = BoxService<ServiceRequest, ServiceResponse, Error>;
|
|
|
|
type HttpNewService = BoxServiceFactory<(), ServiceRequest, ServiceResponse, Error, ()>;
|
2019-03-09 18:49:11 +01:00
|
|
|
|
|
|
|
/// Service factory to convert `Request` to a `ServiceRequest<S>`.
|
2019-03-17 04:17:27 +01:00
|
|
|
/// It also executes data factories.
|
2019-04-13 23:50:54 +02:00
|
|
|
pub struct AppInit<T, B>
|
2019-03-09 18:49:11 +01:00
|
|
|
where
|
2019-11-20 18:33:22 +01:00
|
|
|
T: ServiceFactory<
|
2021-01-04 00:47:04 +01:00
|
|
|
ServiceRequest,
|
2019-05-12 17:34:51 +02:00
|
|
|
Config = (),
|
2019-03-09 18:49:11 +01:00
|
|
|
Response = ServiceResponse<B>,
|
2019-03-11 00:35:38 +01:00
|
|
|
Error = Error,
|
2019-03-09 18:49:11 +01:00
|
|
|
InitError = (),
|
|
|
|
>,
|
|
|
|
{
|
|
|
|
pub(crate) endpoint: T,
|
2019-12-20 12:13:09 +01:00
|
|
|
pub(crate) extensions: RefCell<Option<Extensions>>,
|
2021-01-06 12:35:30 +01:00
|
|
|
pub(crate) async_data_factories: Rc<[FnDataFactory]>,
|
2019-11-20 18:33:22 +01:00
|
|
|
pub(crate) services: Rc<RefCell<Vec<Box<dyn AppServiceFactory>>>>,
|
2019-04-13 23:50:54 +02:00
|
|
|
pub(crate) default: Option<Rc<HttpNewService>>,
|
|
|
|
pub(crate) factory_ref: Rc<RefCell<Option<AppRoutingFactory>>>,
|
2019-03-09 23:06:24 +01:00
|
|
|
pub(crate) external: RefCell<Vec<ResourceDef>>,
|
2019-03-09 18:49:11 +01:00
|
|
|
}
|
|
|
|
|
2021-01-04 00:47:04 +01:00
|
|
|
impl<T, B> ServiceFactory<Request> for AppInit<T, B>
|
2019-03-09 18:49:11 +01:00
|
|
|
where
|
2019-11-20 18:33:22 +01:00
|
|
|
T: ServiceFactory<
|
2021-01-04 00:47:04 +01:00
|
|
|
ServiceRequest,
|
2019-05-12 17:34:51 +02:00
|
|
|
Config = (),
|
2019-03-09 18:49:11 +01:00
|
|
|
Response = ServiceResponse<B>,
|
2019-03-11 00:35:38 +01:00
|
|
|
Error = Error,
|
2019-03-09 18:49:11 +01:00
|
|
|
InitError = (),
|
|
|
|
>,
|
2021-01-06 12:35:30 +01:00
|
|
|
T::Future: 'static,
|
2019-03-09 18:49:11 +01:00
|
|
|
{
|
|
|
|
type Response = ServiceResponse<B>;
|
2019-04-13 23:50:54 +02:00
|
|
|
type Error = T::Error;
|
2021-01-04 00:47:04 +01:00
|
|
|
type Config = AppConfig;
|
2019-04-13 23:50:54 +02:00
|
|
|
type Service = AppInitService<T::Service, B>;
|
2021-01-04 00:47:04 +01:00
|
|
|
type InitError = T::InitError;
|
2021-01-06 12:35:30 +01:00
|
|
|
type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>;
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2019-12-20 11:04:51 +01:00
|
|
|
fn new_service(&self, config: AppConfig) -> Self::Future {
|
2021-01-09 19:06:49 +01:00
|
|
|
// set AppService's default service to 404 NotFound
|
|
|
|
// if no user defined default service exists.
|
2019-03-09 18:49:11 +01:00
|
|
|
let default = self.default.clone().unwrap_or_else(|| {
|
2021-01-06 12:35:30 +01:00
|
|
|
Rc::new(boxed::factory(fn_service(|req: ServiceRequest| async {
|
|
|
|
Ok(req.into_response(Response::NotFound().finish()))
|
2019-03-09 18:49:11 +01:00
|
|
|
})))
|
|
|
|
});
|
|
|
|
|
2019-05-05 04:43:49 +02:00
|
|
|
// App config
|
2021-01-16 00:37:33 +01:00
|
|
|
let mut config = AppService::new(config, default.clone());
|
2019-03-09 18:49:11 +01:00
|
|
|
|
|
|
|
// register services
|
2020-05-17 03:54:42 +02:00
|
|
|
std::mem::take(&mut *self.services.borrow_mut())
|
2019-03-09 18:49:11 +01:00
|
|
|
.into_iter()
|
|
|
|
.for_each(|mut srv| srv.register(&mut config));
|
|
|
|
|
|
|
|
let mut rmap = ResourceMap::new(ResourceDef::new(""));
|
|
|
|
|
2019-05-05 04:43:49 +02:00
|
|
|
let (config, services) = config.into_services();
|
|
|
|
|
2021-01-06 12:35:30 +01:00
|
|
|
// complete pipeline creation.
|
2019-03-09 18:49:11 +01:00
|
|
|
*self.factory_ref.borrow_mut() = Some(AppRoutingFactory {
|
|
|
|
default,
|
2020-10-10 02:26:05 +02:00
|
|
|
services: services
|
|
|
|
.into_iter()
|
|
|
|
.map(|(mut rdef, srv, guards, nested)| {
|
|
|
|
rmap.add(&mut rdef, nested);
|
|
|
|
(rdef, srv, RefCell::new(guards))
|
|
|
|
})
|
|
|
|
.collect::<Vec<_>>()
|
|
|
|
.into_boxed_slice()
|
|
|
|
.into(),
|
2019-03-09 18:49:11 +01:00
|
|
|
});
|
|
|
|
|
2019-03-09 23:06:24 +01:00
|
|
|
// external resources
|
2020-05-17 03:54:42 +02:00
|
|
|
for mut rdef in std::mem::take(&mut *self.external.borrow_mut()) {
|
2019-03-09 23:06:24 +01:00
|
|
|
rmap.add(&mut rdef, None);
|
|
|
|
}
|
|
|
|
|
2019-03-09 18:49:11 +01:00
|
|
|
// complete ResourceMap tree creation
|
|
|
|
let rmap = Rc::new(rmap);
|
|
|
|
rmap.finish(rmap.clone());
|
|
|
|
|
2021-01-06 12:35:30 +01:00
|
|
|
// construct all async data factory futures
|
|
|
|
let factory_futs = join_all(self.async_data_factories.iter().map(|f| f()));
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2021-01-06 12:35:30 +01:00
|
|
|
// construct app service and middleware service factory future.
|
|
|
|
let endpoint_fut = self.endpoint.new_service(());
|
2020-04-29 08:38:53 +02:00
|
|
|
|
2021-01-06 12:35:30 +01:00
|
|
|
// take extensions or create new one as app data container.
|
|
|
|
let mut app_data = self
|
|
|
|
.extensions
|
|
|
|
.borrow_mut()
|
|
|
|
.take()
|
|
|
|
.unwrap_or_else(Extensions::new);
|
2019-06-28 06:43:52 +02:00
|
|
|
|
2021-01-06 12:35:30 +01:00
|
|
|
Box::pin(async move {
|
|
|
|
// async data factories
|
|
|
|
let async_data_factories = factory_futs
|
|
|
|
.await
|
|
|
|
.into_iter()
|
|
|
|
.collect::<Result<Vec<_>, _>>()
|
|
|
|
.map_err(|_| ())?;
|
2020-04-29 08:38:53 +02:00
|
|
|
|
2021-01-06 12:35:30 +01:00
|
|
|
// app service and middleware
|
|
|
|
let service = endpoint_fut.await?;
|
2019-06-28 06:43:52 +02:00
|
|
|
|
2021-01-06 12:35:30 +01:00
|
|
|
// populate app data container from (async) data factories.
|
2021-01-16 00:37:33 +01:00
|
|
|
async_data_factories.iter().for_each(|factory| {
|
|
|
|
factory.create(&mut app_data);
|
|
|
|
});
|
2019-06-28 06:43:52 +02:00
|
|
|
|
2021-01-06 12:35:30 +01:00
|
|
|
Ok(AppInitService {
|
|
|
|
service,
|
|
|
|
app_data: Rc::new(app_data),
|
2021-01-10 23:59:44 +01:00
|
|
|
app_state: AppInitServiceState::new(rmap, config),
|
2021-01-06 12:35:30 +01:00
|
|
|
})
|
|
|
|
})
|
2019-03-09 18:49:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-15 06:38:50 +01:00
|
|
|
/// Service that takes a [`Request`] and delegates to a service that take a [`ServiceRequest`].
|
2019-05-22 20:18:33 +02:00
|
|
|
pub struct AppInitService<T, B>
|
2019-03-09 18:49:11 +01:00
|
|
|
where
|
2021-01-04 00:47:04 +01:00
|
|
|
T: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
2019-03-09 18:49:11 +01:00
|
|
|
{
|
2019-04-13 23:50:54 +02:00
|
|
|
service: T,
|
2021-01-10 23:59:44 +01:00
|
|
|
app_data: Rc<Extensions>,
|
|
|
|
app_state: Rc<AppInitServiceState>,
|
|
|
|
}
|
|
|
|
|
2021-01-15 06:38:50 +01:00
|
|
|
/// A collection of [`AppInitService`] state that shared across `HttpRequest`s.
|
2021-01-10 23:59:44 +01:00
|
|
|
pub(crate) struct AppInitServiceState {
|
2019-03-09 18:49:11 +01:00
|
|
|
rmap: Rc<ResourceMap>,
|
2019-03-09 23:06:24 +01:00
|
|
|
config: AppConfig,
|
2021-01-10 23:59:44 +01:00
|
|
|
pool: HttpRequestPool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AppInitServiceState {
|
|
|
|
pub(crate) fn new(rmap: Rc<ResourceMap>, config: AppConfig) -> Rc<Self> {
|
|
|
|
Rc::new(AppInitServiceState {
|
|
|
|
rmap,
|
|
|
|
config,
|
|
|
|
// TODO: AppConfig can be used to pass user defined HttpRequestPool
|
|
|
|
// capacity.
|
|
|
|
pool: HttpRequestPool::default(),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub(crate) fn rmap(&self) -> &ResourceMap {
|
|
|
|
&*self.rmap
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub(crate) fn config(&self) -> &AppConfig {
|
|
|
|
&self.config
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub(crate) fn pool(&self) -> &HttpRequestPool {
|
|
|
|
&self.pool
|
|
|
|
}
|
2019-03-09 18:49:11 +01:00
|
|
|
}
|
|
|
|
|
2021-01-04 00:47:04 +01:00
|
|
|
impl<T, B> Service<Request> for AppInitService<T, B>
|
2019-03-09 18:49:11 +01:00
|
|
|
where
|
2021-01-04 00:47:04 +01:00
|
|
|
T: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
2019-03-09 18:49:11 +01:00
|
|
|
{
|
2019-04-13 23:50:54 +02:00
|
|
|
type Response = ServiceResponse<B>;
|
|
|
|
type Error = T::Error;
|
|
|
|
type Future = T::Future;
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2021-01-11 02:29:16 +01:00
|
|
|
actix_service::forward_ready!(service);
|
2019-03-09 18:49:11 +01:00
|
|
|
|
|
|
|
fn call(&mut self, req: Request) -> Self::Future {
|
2019-04-08 08:06:21 +02:00
|
|
|
let (head, payload) = req.into_parts();
|
|
|
|
|
2021-01-10 23:59:44 +01:00
|
|
|
let req = if let Some(mut req) = self.app_state.pool().pop() {
|
2021-01-04 01:32:41 +01:00
|
|
|
let inner = Rc::get_mut(&mut req.inner).unwrap();
|
2019-04-08 08:06:21 +02:00
|
|
|
inner.path.get_mut().update(&head.uri);
|
|
|
|
inner.path.reset();
|
|
|
|
inner.head = head;
|
|
|
|
req
|
|
|
|
} else {
|
|
|
|
HttpRequest::new(
|
|
|
|
Path::new(Url::new(head.uri.clone())),
|
|
|
|
head,
|
2021-01-10 23:59:44 +01:00
|
|
|
self.app_state.clone(),
|
2021-01-06 12:35:30 +01:00
|
|
|
self.app_data.clone(),
|
2019-04-08 08:06:21 +02:00
|
|
|
)
|
|
|
|
};
|
2021-01-11 02:29:16 +01:00
|
|
|
self.service.call(ServiceRequest::new(req, payload))
|
2019-03-09 18:49:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-22 20:18:33 +02:00
|
|
|
impl<T, B> Drop for AppInitService<T, B>
|
|
|
|
where
|
2021-01-04 00:47:04 +01:00
|
|
|
T: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
2019-05-22 20:18:33 +02:00
|
|
|
{
|
|
|
|
fn drop(&mut self) {
|
2021-01-10 23:59:44 +01:00
|
|
|
self.app_state.pool().clear();
|
2019-05-22 20:18:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-13 23:50:54 +02:00
|
|
|
pub struct AppRoutingFactory {
|
2020-10-10 02:26:05 +02:00
|
|
|
services: Rc<[(ResourceDef, HttpNewService, RefCell<Option<Guards>>)]>,
|
2019-04-13 23:50:54 +02:00
|
|
|
default: Rc<HttpNewService>,
|
2019-03-09 18:49:11 +01:00
|
|
|
}
|
|
|
|
|
2021-01-04 00:47:04 +01:00
|
|
|
impl ServiceFactory<ServiceRequest> for AppRoutingFactory {
|
2019-03-09 18:49:11 +01:00
|
|
|
type Response = ServiceResponse;
|
2019-03-11 00:35:38 +01:00
|
|
|
type Error = Error;
|
2021-01-06 19:11:20 +01:00
|
|
|
type Config = ();
|
2019-04-13 23:50:54 +02:00
|
|
|
type Service = AppRouting;
|
2021-01-06 19:11:20 +01:00
|
|
|
type InitError = ();
|
|
|
|
type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>;
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2019-12-02 16:37:13 +01:00
|
|
|
fn new_service(&self, _: ()) -> Self::Future {
|
2021-01-06 19:11:20 +01:00
|
|
|
// construct all services factory future with it's resource def and guards.
|
|
|
|
let factory_fut =
|
|
|
|
join_all(self.services.iter().map(|(path, factory, guards)| {
|
|
|
|
let path = path.clone();
|
|
|
|
let guards = guards.borrow_mut().take();
|
|
|
|
let factory_fut = factory.new_service(());
|
|
|
|
async move {
|
|
|
|
let service = factory_fut.await?;
|
|
|
|
Ok((path, guards, service))
|
|
|
|
}
|
|
|
|
}));
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2021-01-06 19:11:20 +01:00
|
|
|
// construct default service factory future
|
|
|
|
let default_fut = self.default.new_service(());
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2021-01-06 19:11:20 +01:00
|
|
|
Box::pin(async move {
|
|
|
|
let default = default_fut.await?;
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2021-01-06 19:11:20 +01:00
|
|
|
// build router from the factory future result.
|
|
|
|
let router = factory_fut
|
|
|
|
.await
|
|
|
|
.into_iter()
|
|
|
|
.collect::<Result<Vec<_>, _>>()?
|
2019-03-09 18:49:11 +01:00
|
|
|
.drain(..)
|
2021-01-06 19:11:20 +01:00
|
|
|
.fold(Router::build(), |mut router, (path, guards, service)| {
|
|
|
|
router.rdef(path, service).2 = guards;
|
2019-03-09 18:49:11 +01:00
|
|
|
router
|
2021-01-06 19:11:20 +01:00
|
|
|
})
|
|
|
|
.finish();
|
|
|
|
|
|
|
|
Ok(AppRouting { router, default })
|
|
|
|
})
|
2019-03-09 18:49:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-13 23:50:54 +02:00
|
|
|
pub struct AppRouting {
|
|
|
|
router: Router<HttpService, Guards>,
|
2021-01-06 19:11:20 +01:00
|
|
|
default: HttpService,
|
2019-03-09 18:49:11 +01:00
|
|
|
}
|
|
|
|
|
2021-01-04 00:47:04 +01:00
|
|
|
impl Service<ServiceRequest> for AppRouting {
|
2019-03-09 18:49:11 +01:00
|
|
|
type Response = ServiceResponse;
|
2019-03-11 00:35:38 +01:00
|
|
|
type Error = Error;
|
2021-01-06 12:35:30 +01:00
|
|
|
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2021-01-06 12:35:30 +01:00
|
|
|
actix_service::always_ready!();
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2019-04-13 23:50:54 +02:00
|
|
|
fn call(&mut self, mut req: ServiceRequest) -> Self::Future {
|
2019-03-09 18:49:11 +01:00
|
|
|
let res = self.router.recognize_mut_checked(&mut req, |req, guards| {
|
|
|
|
if let Some(ref guards) = guards {
|
|
|
|
for f in guards {
|
|
|
|
if !f.check(req.head()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
true
|
|
|
|
});
|
|
|
|
|
|
|
|
if let Some((srv, _info)) = res {
|
2019-04-08 08:06:21 +02:00
|
|
|
srv.call(req)
|
2019-03-09 18:49:11 +01:00
|
|
|
} else {
|
2021-01-06 19:11:20 +01:00
|
|
|
self.default.call(req)
|
2019-03-09 18:49:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Wrapper service for routing
|
2019-04-13 23:50:54 +02:00
|
|
|
pub struct AppEntry {
|
|
|
|
factory: Rc<RefCell<Option<AppRoutingFactory>>>,
|
2019-03-09 18:49:11 +01:00
|
|
|
}
|
|
|
|
|
2019-04-13 23:50:54 +02:00
|
|
|
impl AppEntry {
|
|
|
|
pub fn new(factory: Rc<RefCell<Option<AppRoutingFactory>>>) -> Self {
|
2019-03-09 18:49:11 +01:00
|
|
|
AppEntry { factory }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-04 00:47:04 +01:00
|
|
|
impl ServiceFactory<ServiceRequest> for AppEntry {
|
2019-03-09 18:49:11 +01:00
|
|
|
type Response = ServiceResponse;
|
2019-03-11 00:35:38 +01:00
|
|
|
type Error = Error;
|
2021-01-06 12:35:30 +01:00
|
|
|
type Config = ();
|
2019-04-13 23:50:54 +02:00
|
|
|
type Service = AppRouting;
|
2021-01-06 12:35:30 +01:00
|
|
|
type InitError = ();
|
2021-01-06 19:11:20 +01:00
|
|
|
type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>;
|
2019-03-09 18:49:11 +01:00
|
|
|
|
2019-12-02 16:37:13 +01:00
|
|
|
fn new_service(&self, _: ()) -> Self::Future {
|
|
|
|
self.factory.borrow_mut().as_mut().unwrap().new_service(())
|
2019-03-09 18:49:11 +01:00
|
|
|
}
|
|
|
|
}
|
2019-05-22 20:18:33 +02:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2019-11-26 06:25:50 +01:00
|
|
|
use std::sync::atomic::{AtomicBool, Ordering};
|
|
|
|
use std::sync::Arc;
|
2019-05-22 20:18:33 +02:00
|
|
|
|
2021-01-06 19:11:20 +01:00
|
|
|
use actix_service::Service;
|
|
|
|
|
2019-11-26 06:25:50 +01:00
|
|
|
use crate::test::{init_service, TestRequest};
|
|
|
|
use crate::{web, App, HttpResponse};
|
2019-05-22 20:18:33 +02:00
|
|
|
|
|
|
|
struct DropData(Arc<AtomicBool>);
|
|
|
|
|
|
|
|
impl Drop for DropData {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
self.0.store(true, Ordering::Relaxed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-26 06:25:50 +01:00
|
|
|
#[actix_rt::test]
|
|
|
|
async fn test_drop_data() {
|
2019-05-22 20:18:33 +02:00
|
|
|
let data = Arc::new(AtomicBool::new(false));
|
2019-11-26 06:25:50 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
let mut app = init_service(
|
2019-05-22 20:18:33 +02:00
|
|
|
App::new()
|
|
|
|
.data(DropData(data.clone()))
|
2020-07-22 01:28:33 +02:00
|
|
|
.service(web::resource("/test").to(HttpResponse::Ok)),
|
2019-11-20 18:33:22 +01:00
|
|
|
)
|
|
|
|
.await;
|
2019-11-26 06:25:50 +01:00
|
|
|
let req = TestRequest::with_uri("/test").to_request();
|
2019-11-20 18:33:22 +01:00
|
|
|
let _ = app.call(req).await.unwrap();
|
2019-11-26 06:25:50 +01:00
|
|
|
}
|
2019-05-22 20:18:33 +02:00
|
|
|
assert!(data.load(Ordering::Relaxed));
|
|
|
|
}
|
|
|
|
}
|