From 56aa9c05793b7f2a9f63dbf1fd2f4c419133dbc0 Mon Sep 17 00:00:00 2001 From: des <18638715007@163.com> Date: Sat, 24 Jan 2026 08:15:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=86=9F=E6=82=89=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- Cargo.lock | 13 +++++++++++++ Cargo.toml | 4 +++- src/main.rs | 10 ++++++++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 9ff2cf7..adf7742 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target -*.code-workspace \ No newline at end of file +*.code-workspace +.idea \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 304fadd..8e77b11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,6 +9,7 @@ dependencies = [ "axum", "sea-orm", "shaku", + "tokio", "tracing", "tracing-subscriber", ] @@ -1859,6 +1860,15 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "signal-hook-registry" +version = "1.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7664a098b8e616bdfcc2dc0e9ac44eb231eedf41db4e9fe95d8d32ec728dedad" +dependencies = [ + "libc", +] + [[package]] name = "signature" version = "2.2.0" @@ -2290,9 +2300,12 @@ version = "1.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" dependencies = [ + "bytes", "libc", "mio", + "parking_lot", "pin-project-lite", + "signal-hook-registry", "socket2", "tokio-macros", "windows-sys 0.61.2", diff --git a/Cargo.toml b/Cargo.toml index 6ea95e1..780a95a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,6 @@ shaku = "0.6.2" # WEB 框架 axum = "0.8.8" # 持久层框架 -sea-orm = "2.0.0-rc.28" \ No newline at end of file +sea-orm = "2.0.0-rc.28" +# 异步调度运行时 +tokio = { version = "1", features = ["full"] } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e7a11a9..7664993 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,9 @@ -fn main() { - println!("Hello, world!"); +use axum::{ Router, routing::get, }; + +#[tokio::main] +async fn main() { + let app = Router::new().route("/", get(|| async { "Hello, World!" })); + let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 3000)); + let listener = tokio::net::TcpListener::bind(addr).await.unwrap(); + axum::serve(listener, app).await.unwrap(); }