mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-24 08:07:45 +00:00
Simplify get_login_status and get_world_status
This commit is contained in:
parent
a063de2eb5
commit
891e871b47
1 changed files with 7 additions and 27 deletions
|
@ -5,7 +5,7 @@ use axum::{
|
|||
Router, routing::get,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use kawari::config::Config;
|
||||
use kawari::config::{Config, get_config};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
struct GateStatus {
|
||||
|
@ -13,40 +13,20 @@ struct GateStatus {
|
|||
}
|
||||
|
||||
async fn get_login_status() -> Json<GateStatus> {
|
||||
tracing::info!("Requesting gate status...");
|
||||
|
||||
let mut is_open = 0;
|
||||
|
||||
// read config
|
||||
if let Ok(data) = std::fs::read_to_string("config.json") {
|
||||
let config: Config = serde_json::from_str(&data).expect("Failed to parse");
|
||||
|
||||
if config.login_open {
|
||||
is_open = 1;
|
||||
}
|
||||
}
|
||||
tracing::info!("Requesting login status...");
|
||||
|
||||
let config = get_config();
|
||||
Json(GateStatus {
|
||||
status: is_open
|
||||
status: config.login_open.into()
|
||||
})
|
||||
}
|
||||
|
||||
async fn get_world_status() -> Json<GateStatus> {
|
||||
tracing::info!("Requesting gate status...");
|
||||
|
||||
let mut is_open = 0;
|
||||
|
||||
// read config
|
||||
if let Ok(data) = std::fs::read_to_string("config.json") {
|
||||
let config: Config = serde_json::from_str(&data).expect("Failed to parse");
|
||||
|
||||
if config.worlds_open {
|
||||
is_open = 1;
|
||||
}
|
||||
}
|
||||
tracing::info!("Requesting world status...");
|
||||
|
||||
let config = get_config();
|
||||
Json(GateStatus {
|
||||
status: is_open
|
||||
status: config.login_open.into()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue