1
0
mirror of https://github.com/actix/examples synced 2024-12-12 14:13:11 +01:00
examples/tracing/mainmatter-workshop/src/routes.rs

22 lines
549 B
Rust
Raw Normal View History

use std::time::Duration;
use actix_web::{get, HttpResponse, Responder};
use actix_web_lab::extract::ThinData;
use metrics_exporter_prometheus::PrometheusHandle;
#[get("/hello")]
pub(crate) async fn hello() -> impl Responder {
"Hello, World!"
}
#[get("/sleep")]
pub(crate) async fn sleep() -> impl Responder {
actix_web::rt::time::sleep(Duration::from_millis(500)).await;
HttpResponse::Ok()
}
#[get("/metrics")]
pub(crate) async fn metrics(metrics_handle: ThinData<PrometheusHandle>) -> impl Responder {
metrics_handle.render()
}