From b099cbe497213ac8e30f89aaf88b757464d657d1 Mon Sep 17 00:00:00 2001 From: Ethan O'Brien <77750390+ethanaobrien@users.noreply.github.com> Date: Thu, 28 Mar 2024 11:11:48 -0500 Subject: [PATCH] Add /api/debug/error endpoint --- src/main.rs | 4 ++++ src/router.rs | 1 + src/router/debug.rs | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 src/router/debug.rs diff --git a/src/main.rs b/src/main.rs index 4233f4a..abc49ca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,9 @@ use actix_web::{ dev::Service }; +#[post("/api/debug/error")] +async fn debug_error(req: HttpRequest, body: String) -> HttpResponse { router::debug::error(req, body) } + #[post("/api/start")] async fn start_start(req: HttpRequest, body: String) -> HttpResponse { router::start::start(req, body) } @@ -104,6 +107,7 @@ async fn main() -> std::io::Result<()> { println!("Request: {}", req.path()); srv.call(req) }) + .service(debug_error) .service(login_bonus) .service(reward) .service(live_guest) diff --git a/src/router.rs b/src/router.rs index de928d3..e42be14 100644 --- a/src/router.rs +++ b/src/router.rs @@ -14,3 +14,4 @@ pub mod event; pub mod chat; pub mod story; pub mod notice; +pub mod debug; diff --git a/src/router/debug.rs b/src/router/debug.rs new file mode 100644 index 0000000..cbbf755 --- /dev/null +++ b/src/router/debug.rs @@ -0,0 +1,18 @@ +use json; +use json::{object}; +use crate::router::global; +use crate::encryption; +use actix_web::{HttpResponse, HttpRequest}; + +pub fn error(_req: HttpRequest, body: String) -> HttpResponse { + let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap(); + + println!("client error: {}", body["code"]); + + let resp = object!{ + "code": 4, + "server_time": global::timestamp(), + "message": "" + }; + global::send(resp) +}