added root route
This commit is contained in:
parent
25b3aec69e
commit
5c21843077
1 changed files with 23 additions and 1 deletions
|
|
@ -5,7 +5,9 @@ use prometheus::{Encoder, TextEncoder, Registry};
|
|||
use std::sync::Arc;
|
||||
|
||||
pub async fn run_metrics_server(addr: SocketAddr, registry: Arc<Registry>) {
|
||||
let app = Router::new().route("/metrics", get(move || {
|
||||
let app = Router::new()
|
||||
.route("/", get(root))
|
||||
.route("/metrics", get(move || {
|
||||
let registry = Arc::clone(®istry);
|
||||
async move {
|
||||
let metric_families = registry.gather();
|
||||
|
|
@ -22,3 +24,23 @@ pub async fn run_metrics_server(addr: SocketAddr, registry: Arc<Registry>) {
|
|||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
async fn root() -> http::Response<hyper::Body> {
|
||||
let html = r#"
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Library</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome to the SK Collectors Companion</h1>
|
||||
</body>
|
||||
</html>
|
||||
"#;
|
||||
|
||||
http::Response::builder()
|
||||
.status(http::StatusCode::OK)
|
||||
.header(http::header::CONTENT_TYPE, "text/html")
|
||||
.body(hyper::Body::from(html))
|
||||
.unwrap()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue