init
This commit is contained in:
22
src/main.rs
Normal file
22
src/main.rs
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user