From 029c161e5438fb5aa5b987912ca6ddc35c319b86 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 24 Apr 2025 14:42:01 -0400 Subject: [PATCH] Add stubs for the frontier API used by the client This is the support desk functions, although this doesn't work quite yet and the game complains that it can't recieve any data. --- src/bin/kawari-frontier.rs | 85 +++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 2 deletions(-) diff --git a/src/bin/kawari-frontier.rs b/src/bin/kawari-frontier.rs index 4747aba..1a89dfd 100644 --- a/src/bin/kawari-frontier.rs +++ b/src/bin/kawari-frontier.rs @@ -1,5 +1,11 @@ -use axum::{Json, Router, routing::get}; +use axum::{ + Json, Router, + http::{HeaderValue, Uri}, + response::{IntoResponse, Response}, + routing::{get, post}, +}; use kawari::config::get_config; +use reqwest::{StatusCode, header}; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize)] @@ -65,6 +71,67 @@ async fn get_headline() -> Json { }) } +async fn fallback(uri: Uri) -> (StatusCode, String) { + tracing::warn!("{}", uri); + (StatusCode::NOT_FOUND, format!("No route for {uri}")) +} + +#[derive(Clone, Copy, Debug)] +#[must_use] + +pub struct Xml(pub T); + +impl IntoResponse for Xml +where + T: IntoResponse, +{ + fn into_response(self) -> Response { + ( + [(header::CONTENT_TYPE, HeaderValue::from_static("text/xml"))], + self.0, + ) + .into_response() + } +} + +impl From for Xml { + fn from(inner: T) -> Self { + Self(inner) + } +} + +async fn session_get_init() -> Xml { + // TODO: just a guess + Xml(" +OK + + + + +" + .to_string()) +} + +async fn view_get_init() -> Xml { + Xml(" +OK + + + + +" + .to_string()) +} + +async fn get_headline_all() -> Xml { + Xml(" +OK + + +" + .to_string()) +} + #[tokio::main] async fn main() { tracing_subscriber::fmt::init(); @@ -72,7 +139,21 @@ async fn main() { let app = Router::new() .route("/worldStatus/gate_status.json", get(get_world_status)) .route("/worldStatus/login_status.json", get(get_login_status)) - .route("/news/headline.json", get(get_headline)); + .route("/news/headline.json", get(get_headline)) + // used by the client + .route( + "/frontier-api/ffxivsupport/session/get_init", + post(session_get_init), + ) + .route( + "/frontier-api/ffxivsupport/view/get_init", + get(view_get_init), + ) + .route( + "/frontier-api/ffxivsupport/information/get_headline_all", + get(get_headline_all), + ) + .fallback(fallback); let config = get_config();