From ddc97e9361137fde6f0894ffa729d285159662fa Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 8 Sep 2024 18:46:42 +0100 Subject: Add web crate based on axum --- crates/web/Cargo.toml | 11 +++++++++++ crates/web/src/main.rs | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 crates/web/Cargo.toml create mode 100644 crates/web/src/main.rs (limited to 'crates') diff --git a/crates/web/Cargo.toml b/crates/web/Cargo.toml new file mode 100644 index 0000000..62a3504 --- /dev/null +++ b/crates/web/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "argonaut-web" +version = "0.1.0" +edition = "2021" + +[dependencies] +axum = "0.7.5" +tracing = { workspace = true } +tracing-subscriber = { workspace = true } +tokio = { workspace = true } +serde = { workspace = true } diff --git a/crates/web/src/main.rs b/crates/web/src/main.rs new file mode 100644 index 0000000..f641ce0 --- /dev/null +++ b/crates/web/src/main.rs @@ -0,0 +1,20 @@ +use axum::{ + http::StatusCode, + routing::{get, post}, + Json, Router, +}; +use serde::{Deserialize, Serialize}; + +#[tokio::main(flavor = "current_thread")] +async fn main() { + tracing_subscriber::fmt::init(); + + let app = Router::new().route("/", get(root)); + + let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); + axum::serve(listener, app).await.unwrap(); +} + +async fn root() -> &'static str { + "Hello, World!" +} -- cgit v1.2.3