Add version check system
This commit is contained in:
rust
@ -4,7 +4,7 @@ use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer, Responder};
|
||||
use actix_web_actors::ws;
|
||||
|
||||
use crate::args::Args;
|
||||
use crate::data::{GameRules, PlayConfiguration};
|
||||
use crate::data::{GameRules, PlayConfiguration, VersionInfo};
|
||||
use crate::dispatcher_actor::DispatcherActor;
|
||||
use crate::human_player_ws::{HumanPlayerWS, StartMode};
|
||||
|
||||
@ -18,7 +18,12 @@ async fn not_found() -> impl Responder {
|
||||
HttpResponse::NotFound().json("You missed your strike lol")
|
||||
}
|
||||
|
||||
/// Get bot configuration
|
||||
/// Get version information
|
||||
async fn version_information() -> impl Responder {
|
||||
HttpResponse::Ok().json(VersionInfo::load_static())
|
||||
}
|
||||
|
||||
/// Get game configuration
|
||||
async fn game_configuration() -> impl Responder {
|
||||
HttpResponse::Ok().json(PlayConfiguration::default())
|
||||
}
|
||||
@ -148,6 +153,7 @@ pub async fn start_server(args: Args) -> std::io::Result<()> {
|
||||
App::new()
|
||||
.app_data(web::Data::new(dispatcher_actor.clone()))
|
||||
.wrap(cors)
|
||||
.route("/version", web::get().to(version_information))
|
||||
.route("/config", web::get().to(game_configuration))
|
||||
.route("/play/bot", web::get().to(start_bot_play))
|
||||
.route("/play/create_invite", web::get().to(start_create_invite))
|
||||
|
Reference in New Issue
Block a user