From cd2c571226be112a93491a90be745bc0cfedef25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=9CM=C3=9C=C5=9E?= <96421894+Tahinli@users.noreply.github.com> Date: Fri, 15 Mar 2024 03:37:09 +0300 Subject: [PATCH] refactor: :recycle: status data structures --- back/src/lib.rs | 14 ++++++++++++++ back/src/routing.rs | 17 ++--------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/back/src/lib.rs b/back/src/lib.rs index 2b191cc..d9c68af 100644 --- a/back/src/lib.rs +++ b/back/src/lib.rs @@ -1,6 +1,20 @@ +use serde::{Deserialize, Serialize}; + pub mod routing; +pub mod read; #[derive(Debug, Clone)] pub struct AppState{ +} +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +enum ServerStatus{ + Alive, + Unstable, + Dead, +} +#[derive(Debug, Clone, PartialEq, Serialize,Deserialize)] +enum CoinStatus{ + Tail, + Head, } \ No newline at end of file diff --git a/back/src/routing.rs b/back/src/routing.rs index e9c966e..8caef3c 100644 --- a/back/src/routing.rs +++ b/back/src/routing.rs @@ -1,21 +1,8 @@ -use crate::AppState; +use crate::{AppState, ServerStatus, CoinStatus}; use axum::{extract::State, http::StatusCode, response::IntoResponse, routing::get, Json, Router}; -use serde::{Deserialize, Serialize}; use tower_http::cors::CorsLayer; use rand::prelude::*; -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -enum ServerStatus{ - Alive, - Unstable, - Dead, -} -#[derive(Debug, Clone, PartialEq, Serialize,Deserialize)] -enum CoinStatus{ - Tail, - Head, -} - pub async fn routing(State(state): State) -> Router { Router::new() .route("/", get(alive)) @@ -44,4 +31,4 @@ async fn flip_coin() -> impl IntoResponse { }); println!("{}", coin_json); (StatusCode::OK, Json(coin_json)) -} \ No newline at end of file +}