LCOV - code coverage report
Current view: top level - safekeeper/src/http - mod.rs (source / functions) Coverage Total Hit
Test: c28d23d327d4ca6acc894004f1432d7b7eea829c.info Lines: 0.0 % 39 0
Test Date: 2025-03-21 14:50:36 Functions: 0.0 % 8 0

            Line data    Source code
       1              : pub mod routes;
       2              : use std::sync::Arc;
       3              : 
       4              : use http_utils::tls_certs::ReloadingCertificateResolver;
       5              : pub use routes::make_router;
       6              : pub use safekeeper_api::models;
       7              : use tokio_util::sync::CancellationToken;
       8              : 
       9              : use crate::{GlobalTimelines, SafeKeeperConf};
      10              : 
      11            0 : pub async fn task_main_http(
      12            0 :     conf: Arc<SafeKeeperConf>,
      13            0 :     http_listener: std::net::TcpListener,
      14            0 :     global_timelines: Arc<GlobalTimelines>,
      15            0 : ) -> anyhow::Result<()> {
      16            0 :     let router = make_router(conf, global_timelines)
      17            0 :         .build()
      18            0 :         .map_err(|err| anyhow::anyhow!(err))?;
      19              : 
      20            0 :     let service = Arc::new(
      21            0 :         http_utils::RequestServiceBuilder::new(router).map_err(|err| anyhow::anyhow!(err))?,
      22              :     );
      23            0 :     let server = http_utils::server::Server::new(service, http_listener, None)?;
      24            0 :     server.serve(CancellationToken::new()).await?;
      25            0 :     Ok(()) // unreachable
      26            0 : }
      27              : 
      28            0 : pub async fn task_main_https(
      29            0 :     conf: Arc<SafeKeeperConf>,
      30            0 :     https_listener: std::net::TcpListener,
      31            0 :     global_timelines: Arc<GlobalTimelines>,
      32            0 : ) -> anyhow::Result<()> {
      33            0 :     let cert_resolver = ReloadingCertificateResolver::new(
      34            0 :         &conf.ssl_key_file,
      35            0 :         &conf.ssl_cert_file,
      36            0 :         conf.ssl_cert_reload_period,
      37            0 :     )
      38            0 :     .await?;
      39              : 
      40            0 :     let server_config = rustls::ServerConfig::builder()
      41            0 :         .with_no_client_auth()
      42            0 :         .with_cert_resolver(cert_resolver);
      43            0 : 
      44            0 :     let tls_acceptor = tokio_rustls::TlsAcceptor::from(Arc::new(server_config));
      45              : 
      46            0 :     let router = make_router(conf, global_timelines)
      47            0 :         .build()
      48            0 :         .map_err(|err| anyhow::anyhow!(err))?;
      49              : 
      50            0 :     let service = Arc::new(
      51            0 :         http_utils::RequestServiceBuilder::new(router).map_err(|err| anyhow::anyhow!(err))?,
      52              :     );
      53            0 :     let server = http_utils::server::Server::new(service, https_listener, Some(tls_acceptor))?;
      54            0 :     server.serve(CancellationToken::new()).await?;
      55            0 :     Ok(()) // unreachable
      56            0 : }
        

Generated by: LCOV version 2.1-beta