From da21eb11890452b81eb7ecb8d2988683713c7bf4 Mon Sep 17 00:00:00 2001 From: supercmmetry Date: Wed, 24 Jun 2020 13:45:35 +0530 Subject: [PATCH] treewide: Migrate to clean-architecture Signed-off-by: supercmmetry --- src/api/catchers/mod.rs | 0 src/api/guards/mod.rs | 0 src/api/misc/mod.rs | 0 src/api/mod.rs | 5 +++++ src/api/routes/health.rs | 11 +++++++++++ src/api/routes/mod.rs | 12 ++++++++++++ src/core/mod.rs | 1 + src/core/paste/diesel.rs | 0 src/core/paste/entity.rs | 0 src/core/paste/mod.rs | 4 ++++ src/core/paste/repository.rs | 0 src/core/paste/service.rs | 0 src/main.rs | 16 +++++++++------- 13 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 src/api/catchers/mod.rs create mode 100644 src/api/guards/mod.rs create mode 100644 src/api/misc/mod.rs create mode 100644 src/api/mod.rs create mode 100644 src/api/routes/health.rs create mode 100644 src/api/routes/mod.rs create mode 100644 src/core/mod.rs create mode 100644 src/core/paste/diesel.rs create mode 100644 src/core/paste/entity.rs create mode 100644 src/core/paste/mod.rs create mode 100644 src/core/paste/repository.rs create mode 100644 src/core/paste/service.rs diff --git a/src/api/catchers/mod.rs b/src/api/catchers/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/api/guards/mod.rs b/src/api/guards/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/api/misc/mod.rs b/src/api/misc/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/api/mod.rs b/src/api/mod.rs new file mode 100644 index 0000000..b6aba30 --- /dev/null +++ b/src/api/mod.rs @@ -0,0 +1,5 @@ +pub mod routes; +pub mod catchers; + +mod guards; +mod misc; diff --git a/src/api/routes/health.rs b/src/api/routes/health.rs new file mode 100644 index 0000000..0201b31 --- /dev/null +++ b/src/api/routes/health.rs @@ -0,0 +1,11 @@ +use rocket::Rocket; + +#[get("/check")] +fn check() -> &'static str { + "OK" +} + + +pub fn fuel(rocket: Rocket) -> Rocket { + rocket.mount("/api/health", routes![check]) +} \ No newline at end of file diff --git a/src/api/routes/mod.rs b/src/api/routes/mod.rs new file mode 100644 index 0000000..9390295 --- /dev/null +++ b/src/api/routes/mod.rs @@ -0,0 +1,12 @@ +use rocket::Rocket; + +pub mod health; + +pub fn fuel(rocket: Rocket) -> Rocket { + let mut rocket = rocket; + + rocket = health::fuel(rocket); + + rocket +} + diff --git a/src/core/mod.rs b/src/core/mod.rs new file mode 100644 index 0000000..8be33e3 --- /dev/null +++ b/src/core/mod.rs @@ -0,0 +1 @@ +pub mod paste; \ No newline at end of file diff --git a/src/core/paste/diesel.rs b/src/core/paste/diesel.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/core/paste/entity.rs b/src/core/paste/entity.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/core/paste/mod.rs b/src/core/paste/mod.rs new file mode 100644 index 0000000..17f177d --- /dev/null +++ b/src/core/paste/mod.rs @@ -0,0 +1,4 @@ +pub mod entity; +pub mod repository; +pub mod diesel; +pub mod service; \ No newline at end of file diff --git a/src/core/paste/repository.rs b/src/core/paste/repository.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/core/paste/service.rs b/src/core/paste/service.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/main.rs index d460bcb..433f3aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,13 +3,15 @@ #[macro_use] extern crate rocket; -#[get("/alive")] -fn alive() -> &'static str { - "OK" -} +pub mod api; +pub mod core; + + fn main() { - rocket::ignite() - .mount("/", routes![index]) - .launch(); + let mut rocket = rocket::ignite(); + + rocket = api::routes::fuel(rocket); + + rocket.launch(); }