LCOV - differential code coverage report
Current view: top level - proxy/src/http - health_server.rs (source / functions) Coverage Total Hit UBC CBC
Current: cd44433dd675caa99df17a61b18949c8387e2242.info Lines: 88.9 % 18 16 2 16
Current Date: 2024-01-09 02:06:09 Functions: 88.9 % 9 8 1 8
Baseline: 66c52a629a0f4a503e193045e0df4c77139e344b.info
Baseline Date: 2024-01-08 15:34:46

           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          22 : async fn status_handler(_: Request<Body>) -> Result<Response<Body>, ApiError> {
       8              22 :     json_response(StatusCode::OK, "")
       9              22 : }
      10                 : 
      11              22 : fn make_router() -> RouterBuilder<hyper::Body, ApiError> {
      12              22 :     endpoint::make_router().get("/v1/status", status_handler)
      13              22 : }
      14                 : 
      15              22 : pub async fn task_main(http_listener: TcpListener) -> anyhow::Result<Infallible> {
      16              22 :     scopeguard::defer! {
      17              22 :         info!("http has shut down");
      18              22 :     }
      19              22 : 
      20              22 :     let service = || RouterService::new(make_router().build()?);
      21              22 : 
      22              22 :     hyper::Server::from_tcp(http_listener)?
      23              22 :         .serve(service().map_err(|e| anyhow!(e))?)
      24              23 :         .await?;
      25                 : 
      26 UBC           0 :     bail!("hyper server without shutdown handling cannot shutdown successfully");
      27               0 : }
        

Generated by: LCOV version 2.1-beta