From 877cf3bac05d9cf786db3ae45202b2d4d9a98a5c Mon Sep 17 00:00:00 2001 From: nain <126972030+nain-F49FF806@users.noreply.github.com> Date: Fri, 23 Jun 2023 16:16:35 +0200 Subject: [PATCH] refactor(crate): Move handler to separate (sub)module --- src/main.rs | 1 + src/router.rs | 7 ++----- src/routes/hello_world.rs | 6 ++++++ src/routes/mod.rs | 4 ++++ 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 src/routes/hello_world.rs create mode 100644 src/routes/mod.rs diff --git a/src/main.rs b/src/main.rs index aa3240f..b4ec098 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ // Copyright 2023 Naian G. // SPDX-License-Identifier: Apache-2.0 mod router; +mod routes; mod server; use server::run_server; diff --git a/src/router.rs b/src/router.rs index 071b7f2..1bd903c 100644 --- a/src/router.rs +++ b/src/router.rs @@ -1,12 +1,9 @@ // Copyright 2023 Naian G. // SPDX-License-Identifier: Apache-2.0 use axum::{Router, routing::get}; +use crate::routes::hello_world; pub fn create_router() -> Router { - let app = Router::new().route("/", get(handle_get)); + let app = Router::new().route("/", get(hello_world::handle_get)); return app; } - -async fn handle_get() -> String { - "hey".to_owned() -} \ No newline at end of file diff --git a/src/routes/hello_world.rs b/src/routes/hello_world.rs new file mode 100644 index 0000000..2180e03 --- /dev/null +++ b/src/routes/hello_world.rs @@ -0,0 +1,6 @@ +// Copyright 2023 Naian G. +// SPDX-License-Identifier: Apache-2.0 + +pub async fn handle_get() -> String { + "hey".to_owned() +} \ No newline at end of file diff --git a/src/routes/mod.rs b/src/routes/mod.rs new file mode 100644 index 0000000..c04f4ea --- /dev/null +++ b/src/routes/mod.rs @@ -0,0 +1,4 @@ +// Copyright 2023 Naian G. +// SPDX-License-Identifier: Apache-2.0 + +pub mod hello_world;