/// Handles an incoming HTTP request by parsing the URL, handing over to
/// `route_request()` and replying with the produced response.
Handles an incoming HTTP request by parsing the URL, handing over to
`route_request()` and replying with the produced response.
Handles an incoming HTTP request by parsing the URL handing over to ` route_request () ` and replying with the produced response .
async fn handle_http_request(
    request: Request,
    base_url: Arc<Url>,
    metrics: Arc<ProberMetrics>,
    registry: Arc<MetricsRegistry>,
    log: Arc<Logger>,
) {
    let timer = Timer::start();
    let url = request.url();
    let (path, status, response) = match base_url.join(url) {
        Ok(url) => {
            let deadline = probe_deadline(&request, &log);
            route_request(url, deadline, &metrics, &registry, &log).await
        }
        Err(e) => {
            let msg = format!("Invalid URL {}: {}", url, e);
            warn!(log, "{}", msg);
            (
                OTHER_PATH,
                STATUS_CODE_BAD_REQUEST,
                Response::from_data(msg).with_status_code(STATUS_CODE_BAD_REQUEST),
            )
        }
    };
    request
        .respond(response)
        .unwrap_or_else(|e| warn!(log, "Error responding: {}", e));
    metrics
        .request_duration
        .with_label_values(&[path, &status.0.to_string()])
        .observe(timer.elapsed());
}
async fn handle_http_request ( request : Request , base_url : Arc < Url > , metrics : Arc < ProberMetrics > , registry : Arc < MetricsRegistry > , log : Arc < Logger > , ) { let timer = Timer :: start ( ) ; let url = request . url ( ) ; let ( path , status , response ) = match base_url . join ( url ) { Ok ( url ) => { let deadline = probe_deadline ( & request , & log ) ; route_request ( url , deadline , & metrics , & registry , & log ) . await } Err ( e ) => { let msg = format ! ( " " url e ) ; warn ! ( log " " msg ) ; ( OTHER_PATH , STATUS_CODE_BAD_REQUEST , Response :: from_data ( msg ) . with_status_code ( STATUS_CODE_BAD_REQUEST ) , ) } } ; request . respond ( response ) . unwrap_or_else ( | e | warn ! ( log " " e ) ) ; metrics . request_duration . with_label_values ( & [ path , & status . 0 . to_string ( ) ] ) . observe ( timer . elapsed ( ) ) ; }
Handles an incoming HTTP request by parsing the URL, handing over to
`route_request()` and replying with the produced response.
Handles an incoming HTTP request by parsing the URL handing over to ` route_request () ` and replying with the produced response .
request
Request
base_url
Arc<Url>
metrics
Arc<ProberMetrics>
registry
Arc<MetricsRegistry>
log
Arc<Logger>