From 88aaf3d0d66966f093b515ed7bc1f5f499319f08 Mon Sep 17 00:00:00 2001 From: Ninjdai Date: Thu, 7 Aug 2025 21:43:37 +0200 Subject: [PATCH] feat: make API available at /api instead of at root of the server --- src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 10e35eb..7595d37 100644 --- a/src/main.rs +++ b/src/main.rs @@ -171,7 +171,7 @@ async fn run_server(db: Arc, port: u16) { } } - let (router, mut api) = OpenApiRouter::new() + let open_api_router = OpenApiRouter::new() // Book API .routes(routes!(routes::book::get_book_by_ean)) .routes(routes!(routes::book::get_book_by_id)) @@ -200,8 +200,12 @@ async fn run_server(db: Arc, port: u16) { .routes(routes!(routes::auth::check_token)) // Misc .routes(routes!(routes::websocket::ws_handler)) - .route("/", get(index)) + .with_state(shared_state.clone()); + + let (router, mut api) = OpenApiRouter::new() + .nest("/api", open_api_router) + .route("/", get(index)) // temporary index page, will redirect/proxy to flutter app .with_state(shared_state) .split_for_parts();