refactor: ♻️ status data structures
This commit is contained in:
parent
a6e95affab
commit
cd2c571226
2 changed files with 16 additions and 15 deletions
|
@ -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,
|
||||
}
|
|
@ -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<AppState>) -> Router {
|
||||
Router::new()
|
||||
.route("/", get(alive))
|
||||
|
@ -44,4 +31,4 @@ async fn flip_coin() -> impl IntoResponse {
|
|||
});
|
||||
println!("{}", coin_json);
|
||||
(StatusCode::OK, Json(coin_json))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue