Line data Source code
1 : pub mod client;
2 : pub mod routes;
3 : pub use routes::make_router;
4 :
5 : pub use safekeeper_api::models;
6 : use std::sync::Arc;
7 :
8 : use crate::{GlobalTimelines, SafeKeeperConf};
9 :
10 0 : pub async fn task_main(
11 0 : conf: Arc<SafeKeeperConf>,
12 0 : http_listener: std::net::TcpListener,
13 0 : global_timelines: Arc<GlobalTimelines>,
14 0 : ) -> anyhow::Result<()> {
15 0 : let router = make_router(conf, global_timelines)
16 0 : .build()
17 0 : .map_err(|err| anyhow::anyhow!(err))?;
18 0 : let service = utils::http::RouterService::new(router).unwrap();
19 0 : let server = hyper::Server::from_tcp(http_listener)?;
20 0 : server.serve(service).await?;
21 0 : Ok(()) // unreachable
22 0 : }
|