Added system/info endpoint, implement tagging
This commit is contained in:
31
api/src/system/mod.rs
Normal file
31
api/src/system/mod.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use std::env;
|
||||
use actix_web::{get, web, HttpResponse};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct SystemInfo {
|
||||
version: String,
|
||||
healthy: bool,
|
||||
}
|
||||
|
||||
#[get("/info")]
|
||||
async fn info() -> HttpResponse {
|
||||
let mut healthy = true;
|
||||
let version = match env::var("API_VERSION") {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
healthy = false;
|
||||
String::from("unknown")
|
||||
}
|
||||
};
|
||||
|
||||
dbg!(&version);
|
||||
|
||||
let info = SystemInfo { version, healthy };
|
||||
|
||||
HttpResponse::Ok().json(info)
|
||||
}
|
||||
|
||||
pub fn init_routes(config: &mut web::ServiceConfig) {
|
||||
config.service(web::scope("/system").service(info));
|
||||
}
|
||||
Reference in New Issue
Block a user