Skip to content

Commit

Permalink
feat: hide fancy frontend behind a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Erin van der Veen committed Apr 12, 2024
1 parent 3be2036 commit 4f52e35
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions genealogos-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
10 changes: 10 additions & 0 deletions genealogos-api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@ fn handle_errors(req: &Request) -> status::Custom<String> {
}

#[rocket::get("/")]
#[cfg(feature = "frontend")]
fn index() -> status::Custom<content::RawHtml<&'static str>> {
status::Custom(
Status::Ok,
content::RawHtml(include_str!("../../genealogos-frontend/index.html")),
)
}

#[rocket::get("/")]
#[cfg(not(feature = "frontend"))]
fn index() -> status::Custom<content::RawHtml<&'static str>> {
status::Custom(
Status::Ok,
content::RawHtml("<h1>Genealogos is running</h1>"),
)
}

#[rocket::get("/analyze?<installable>&<bom_format>")]
fn analyze(installable: &str, bom_format: Option<BomArg>) -> Result<messages::AnalyzeResponse> {
let start_time = std::time::Instant::now();
Expand Down

0 comments on commit 4f52e35

Please sign in to comment.