From ec9b0993bcb7787fa44d3ae3a02977e78b47915f Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sat, 10 Feb 2024 10:13:11 +0000 Subject: [PATCH] Move axum stuff to separate module --- src/main.rs | 6 ++---- src/server.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 src/server.rs diff --git a/src/main.rs b/src/main.rs index 13ead3a..c20990a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,8 +20,8 @@ #![forbid(unsafe_code)] mod auth; +mod server; -use axum::{routing::get, Router}; use color_eyre::Result; use tracing::{event, instrument, Level}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; @@ -50,9 +50,7 @@ async fn main() -> Result<()> { event!(Level::INFO, "Hello, world!"); - let app = Router::new().route("/tls-check/success", get(|| async { "OK" })); - let listener = tokio::net::TcpListener::bind("[::]:8080").await?; - axum::serve(listener, app).await?; + tokio::spawn(server::run()).await??; Ok(()) } diff --git a/src/server.rs b/src/server.rs new file mode 100644 index 0000000..cc2a5e5 --- /dev/null +++ b/src/server.rs @@ -0,0 +1,12 @@ +use axum::{routing::get, Router}; +use color_eyre::Result; +use tracing::instrument; + +#[instrument] +pub async fn run() -> Result<()> { + let app = Router::new().route("/tls-check/success", get(|| async { "OK" })); + let listener = tokio::net::TcpListener::bind("[::]:8080").await?; + axum::serve(listener, app).await?; + + Ok(()) +}