This commit is contained in:
quantulr
2024-01-18 14:03:08 +08:00
commit fda538adbb
8 changed files with 1475 additions and 0 deletions

22
src/main.rs Normal file
View File

@ -0,0 +1,22 @@
use axum::{routing::get, Router};
use axum::http::StatusCode;
async fn event_rcv_handle() -> Result<String, (StatusCode, String)> {
tokio::spawn(async {
println!("收到告警,向飞书推送消息");
reqwest::get("https://www.feishu.cn/flow/api/trigger-webhook/d96aa14944ed0595d831e9d68834b47b?content=收到告警信息").await
});
Ok(String::from("success"))
}
#[tokio::main]
async fn main() {
// build our application with a single route
let app = Router::new()
.route("/", get(|| async { "Hello, World!" }))
.route("/eventRcv", get(event_rcv_handle));
// run our app with hyper, listening globally on port 3000
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}