From 4f52e3537e320924cf5f2b6b906e6e4b5f031757 Mon Sep 17 00:00:00 2001 From: Erin van der Veen Date: Fri, 12 Apr 2024 15:15:52 +0200 Subject: [PATCH] feat: hide fancy frontend behind a feature flag --- genealogos-api/Cargo.toml | 5 +++++ genealogos-api/src/main.rs | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/genealogos-api/Cargo.toml b/genealogos-api/Cargo.toml index 0067aa7..7730789 100644 --- a/genealogos-api/Cargo.toml +++ b/genealogos-api/Cargo.toml @@ -31,6 +31,11 @@ urlencoding.workspace = true pretty_assertions.workspace = true [features] +default = [ "frontend" ] + # This feature should be enabled when running tests in a Nix environment. # It disables all tests that require a working internet connection. nix = [] + +# Enabling this feature makes Genealogos server a gui frontend at IP:PORT/ +frontend = [] diff --git a/genealogos-api/src/main.rs b/genealogos-api/src/main.rs index c1e6254..98c820c 100644 --- a/genealogos-api/src/main.rs +++ b/genealogos-api/src/main.rs @@ -23,6 +23,7 @@ fn handle_errors(req: &Request) -> status::Custom { } #[rocket::get("/")] +#[cfg(feature = "frontend")] fn index() -> status::Custom> { status::Custom( Status::Ok, @@ -30,6 +31,15 @@ fn index() -> status::Custom> { ) } +#[rocket::get("/")] +#[cfg(not(feature = "frontend"))] +fn index() -> status::Custom> { + status::Custom( + Status::Ok, + content::RawHtml("

Genealogos is running

"), + ) +} + #[rocket::get("/analyze?&")] fn analyze(installable: &str, bom_format: Option) -> Result { let start_time = std::time::Instant::now();