LCOV - differential code coverage report
Current view: top level - proxy/src/http - server.rs (source / functions) Coverage Total Hit UBC CBC
Current: f6946e90941b557c917ac98cd5a7e9506d180f3e.info Lines: 88.9 % 18 16 2 16
Current Date: 2023-10-19 02:04:12 Functions: 88.9 % 9 8 1 8
Baseline: c8637f37369098875162f194f92736355783b050.info
Baseline Date: 2023-10-18 20:25:20

           TLA  Line data    Source code
       1                 : use anyhow::{anyhow, bail};
       2                 : use hyper::{Body, Request, Response, StatusCode};
       3                 : use std::{convert::Infallible, net::TcpListener};
       4                 : use tracing::info;
       5                 : use utils::http::{endpoint, error::ApiError, json::json_response, RouterBuilder, RouterService};
       6                 : 
       7 CBC          16 : async fn status_handler(_: Request<Body>) -> Result<Response<Body>, ApiError> {
       8              16 :     json_response(StatusCode::OK, "")
       9              16 : }
      10                 : 
      11              16 : fn make_router() -> RouterBuilder<hyper::Body, ApiError> {
      12              16 :     endpoint::make_router().get("/v1/status", status_handler)
      13              16 : }
      14                 : 
      15              16 : pub async fn task_main(http_listener: TcpListener) -> anyhow::Result<Infallible> {
      16              16 :     scopeguard::defer! {
      17              16 :         info!("http has shut down");
      18              16 :     }
      19              16 : 
      20              16 :     let service = || RouterService::new(make_router().build()?);
      21              16 : 
      22              16 :     hyper::Server::from_tcp(http_listener)?
      23              16 :         .serve(service().map_err(|e| anyhow!(e))?)
      24              17 :         .await?;
      25                 : 
      26 UBC           0 :     bail!("hyper server without shutdown handling cannot shutdown successfully");
      27               0 : }
        

Generated by: LCOV version 2.1-beta