diff options
author | Galen Guyer <galen@galenguyer.com> | 2022-05-31 21:35:03 -0400 |
---|---|---|
committer | Galen Guyer <galen@galenguyer.com> | 2022-05-31 21:35:03 -0400 |
commit | ea58034b765696389d343e5d009bb9c46efb909b (patch) | |
tree | e07d335e4528a05a315a19f0b054ccbbc702d644 | |
parent | c1beee3bd01615753ded3d2bbc4c4caf5a5f7ff0 (diff) |
add features route
-rw-r--r-- | src/main.rs | 1 | ||||
-rw-r--r-- | src/routes/v1/features.rs | 10 | ||||
-rw-r--r-- | src/routes/v1/mod.rs | 1 |
3 files changed, 12 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 2ac7afd..8c4a9ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,6 +53,7 @@ async fn main() { Router::new().nest( "/v1", Router::new() + .route("/features", get(routes::v1::features::get_features)) .nest( "/users", Router::new() diff --git a/src/routes/v1/features.rs b/src/routes/v1/features.rs new file mode 100644 index 0000000..b9d474d --- /dev/null +++ b/src/routes/v1/features.rs @@ -0,0 +1,10 @@ +use axum::{response::IntoResponse, http::StatusCode}; +use crate::extractors::Json; +use serde_json::json; + +pub async fn get_features() -> impl IntoResponse { + (StatusCode::OK, Json(json!({ + "totp": option_env!("FDNS_TOTP_ENABLED").unwrap_or("false").parse::<bool>().unwrap_or(false), + "signup": option_env!("FDNS_SIGNUP_ENABLED").unwrap_or("false").parse::<bool>().unwrap_or(false), + }))) +} diff --git a/src/routes/v1/mod.rs b/src/routes/v1/mod.rs index f561d02..973ac03 100644 --- a/src/routes/v1/mod.rs +++ b/src/routes/v1/mod.rs @@ -1,5 +1,6 @@ pub mod records; pub mod users; pub mod zones; +pub mod features; mod requests; |