use base64::Engine; use axum::{response::{Response, IntoResponse}, Json, http::StatusCode}; use serde::Serialize; pub mod join; pub mod has_joined; pub mod profile; pub mod textures; pub use join::join; pub use has_joined::has_joined; pub use profile::profile; pub use textures::serve_texture; #[derive(Serialize)] pub struct HasJoinedResponse { id: String, name: String, properties: Vec, } #[derive(Serialize)] pub struct HasJoinedProperty { name: String, value: String, } fn create_profile_response(uuid: String, username: String) -> Response { let textures = serde_json::json!({ "timestamp": chrono::Utc::now().timestamp(), "profileId": uuid, "profileName": username, "textures": { "SKIN": { "url": format!("http://root-kit.ru:3001/textures/skin/{}.png", uuid), "metadata": { "model": "slim" } }, "CAPE": { "url": format!("http://root-kit.ru:3001/textures/cape/{}.png", uuid), } } }); let textures_base64 = base64::engine::general_purpose::STANDARD.encode(textures.to_string()); let response = HasJoinedResponse { id: uuid, name: username.clone(), properties: vec![HasJoinedProperty { name: "textures".to_string(), value: textures_base64, }], }; (StatusCode::OK, Json(response)).into_response() }