From 426989350e40c0e5309bba77056bfd24ac8b2920 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 18 Feb 2024 22:08:06 +0800 Subject: [PATCH] Implement download --- apps/gpservice/src/handlers.rs | 8 ++++++++ apps/gpservice/src/routes.rs | 1 + 2 files changed, 9 insertions(+) diff --git a/apps/gpservice/src/handlers.rs b/apps/gpservice/src/handlers.rs index 1afdb6d..cc36c44 100644 --- a/apps/gpservice/src/handlers.rs +++ b/apps/gpservice/src/handlers.rs @@ -1,6 +1,7 @@ use std::{borrow::Cow, ops::ControlFlow, sync::Arc}; use axum::{ + body::Bytes, extract::{ ws::{self, CloseFrame, Message, WebSocket}, State, WebSocketUpgrade, @@ -25,6 +26,13 @@ pub(crate) async fn auth_data(State(ctx): State>, body: Str ctx.send_event(WsEvent::AuthData(body)).await; } +pub(crate) struct UpdateGuiPayload { + pub(crate) file: String, + pub(crate) checksum: String, +} + +pub async fn update_gui(State(ctx): State>, body: Bytes) -> impl IntoResponse {} + pub(crate) async fn ws_handler(ws: WebSocketUpgrade, State(ctx): State>) -> impl IntoResponse { ws.on_upgrade(move |socket| handle_socket(socket, ctx)) } diff --git a/apps/gpservice/src/routes.rs b/apps/gpservice/src/routes.rs index 45e1393..0f2ff22 100644 --- a/apps/gpservice/src/routes.rs +++ b/apps/gpservice/src/routes.rs @@ -12,6 +12,7 @@ pub(crate) fn routes(ctx: Arc) -> Router { .route("/health", get(handlers::health)) .route("/active-gui", post(handlers::active_gui)) .route("/auth-data", post(handlers::auth_data)) + .route("/update-gui", post(handlers::update_gui)) .route("/ws", get(handlers::ws_handler)) .with_state(ctx) }