(
addr: net::SocketAddr,
access_token: Option<String>,
cors: Option<String>,
query: Arc<Query>,
sync_tx: mpsc::Sender<()>,
)
| 522 | |
| 523 | impl HttpServer { |
| 524 | pub fn start( |
| 525 | addr: net::SocketAddr, |
| 526 | access_token: Option<String>, |
| 527 | cors: Option<String>, |
| 528 | query: Arc<Query>, |
| 529 | sync_tx: mpsc::Sender<()>, |
| 530 | ) -> Self { |
| 531 | let listeners = Arc::new(Mutex::new(Vec::new())); |
| 532 | let sync_tx = Arc::new(Mutex::new(sync_tx)); |
| 533 | let warp_server = setup(access_token, cors, query, sync_tx, listeners.clone()); |
| 534 | |
| 535 | let (shutdown_tx, shutdown_rx) = oneshot::channel(); |
| 536 | let (addr_tx, addr_rx) = oneshot::channel(); |
| 537 | |
| 538 | let thread = thread::spawn(move || { |
| 539 | spawn(warp_server, addr, addr_tx, shutdown_rx); |
| 540 | }); |
| 541 | |
| 542 | let bound_addr = block_on_future(addr_rx).expect("failed starting http server"); |
| 543 | info!("HTTP REST API server running on http://{}/", bound_addr); |
| 544 | |
| 545 | HttpServer { |
| 546 | listeners, |
| 547 | addr: bound_addr, |
| 548 | shutdown_tx: Some(shutdown_tx), |
| 549 | thread: Some(thread), |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | pub fn send_updates(&self, changelog: &[IndexChange]) { |
| 554 | let mut listeners = self.listeners.lock().unwrap(); |
nothing calls this directly
no test coverage detected