Skip to content

Commit 8a0220a

Browse files
committed
feat: add health check api use axum
1 parent c65cd13 commit 8a0220a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/main.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,24 @@ mod link;
33
mod schedule;
44

55
use crate::schedule::check_repository_links;
6+
use axum::{Router, routing::get};
67
use std::time::Duration;
78

9+
async fn health_check() -> &'static str {
10+
"OK"
11+
}
12+
813
#[tokio::main]
914
async fn main() {
15+
let app = Router::new().route("/check", get(health_check));
16+
17+
let listener = tokio::net::TcpListener::bind("localhost:3000")
18+
.await
19+
.unwrap();
20+
1021
let repo_url = "https://github.com/reddevilmidzy/redddy-action";
1122
let interval_duration = Duration::from_secs(60);
12-
check_repository_links(repo_url, interval_duration).await;
23+
let _repo_check = check_repository_links(repo_url, interval_duration);
24+
25+
axum::serve(listener, app).await.unwrap();
1326
}

0 commit comments

Comments
 (0)