MCPcopy Create free account
hub / github.com/bwt-dev/bwt / start

Method start

src/http.rs:524–551  ·  view source on GitHub ↗
(
        addr: net::SocketAddr,
        access_token: Option<String>,
        cors: Option<String>,
        query: Arc<Query>,
        sync_tx: mpsc::Sender<()>,
    )

Source from the content-addressed store, hash-verified

522
523impl 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();

Callers

nothing calls this directly

Calls 3

setupFunction · 0.85
spawnFunction · 0.85
block_on_futureFunction · 0.85

Tested by

no test coverage detected