|
|
@ -32,7 +32,6 @@ pub struct API<'a> { |
|
|
|
user_service: Arc<RwLock<user_service::UserService>>, |
|
|
|
user_service: Arc<RwLock<user_service::UserService>>, |
|
|
|
metric_service: metric_service::MetricService, |
|
|
|
metric_service: metric_service::MetricService, |
|
|
|
segments_service: segments_service::SegmentsService, |
|
|
|
segments_service: segments_service::SegmentsService, |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl API<'_> { |
|
|
|
impl API<'_> { |
|
|
@ -70,8 +69,8 @@ impl API<'_> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub async fn serve(&self) { |
|
|
|
pub async fn serve(&self) { |
|
|
|
|
|
|
|
let mut analytic_service = |
|
|
|
let mut analytic_service = AnalyticService::new(self.metric_service.clone(), self.segments_service.clone()); |
|
|
|
AnalyticService::new(self.metric_service.clone(), self.segments_service.clone()); |
|
|
|
|
|
|
|
|
|
|
|
let not_found = |
|
|
|
let not_found = |
|
|
|
warp::any().map(|| warp::reply::with_status("Not found", StatusCode::NOT_FOUND)); |
|
|
|
warp::any().map(|| warp::reply::with_status("Not found", StatusCode::NOT_FOUND)); |
|
|
@ -97,10 +96,8 @@ impl API<'_> { |
|
|
|
.or(not_found); |
|
|
|
.or(not_found); |
|
|
|
|
|
|
|
|
|
|
|
let s1 = analytic_service.serve(); |
|
|
|
let s1 = analytic_service.serve(); |
|
|
|
let s2 = warp::serve(routes) |
|
|
|
let s2 = warp::serve(routes).run(([127, 0, 0, 1], self.config.port)); |
|
|
|
.run(([127, 0, 0, 1], self.config.port)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
futures::future::join(s1, s2).await; |
|
|
|
futures::future::join(s1, s2).await; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|