fn handle_http_request()

in src/core/admin/src/lib.rs [605:644]


    fn handle_http_request(&self, request: Request) {
        let url = request.url();
        let parts: Vec<&str> = url.split('?').collect();
        let url = parts[0];
        match url {
            // Prometheus/OpenTelemetry expect the `/metrics` URI will return
            // stats in the Prometheus format
            "/metrics" => match request.method() {
                Method::Get => {
                    let _ = request.respond(Response::from_string(self.prometheus_stats()));
                }
                _ => {
                    let _ = request.respond(Response::empty(400));
                }
            },
            // we export Finagle/TwitterServer format stats on a few endpoints
            // for maximum compatibility with various internal conventions
            "/metrics.json" | "/vars.json" | "/admin/metrics.json" => match request.method() {
                Method::Get => {
                    let _ = request.respond(Response::from_string(self.json_stats()));
                }
                _ => {
                    let _ = request.respond(Response::empty(400));
                }
            },
            // human-readable stats are exported on the `/vars` endpoint based
            // on internal conventions
            "/vars" => match request.method() {
                Method::Get => {
                    let _ = request.respond(Response::from_string(self.human_stats()));
                }
                _ => {
                    let _ = request.respond(Response::empty(400));
                }
            },
            _ => {
                let _ = request.respond(Response::empty(404));
            }
        }
    }