feat: add /build route (#6644)

This commit is contained in:
Prospector
2026-07-07 15:43:26 +00:00
committed by GitHub
parent 517c3d2d72
commit df8ebbd3e0
2 changed files with 13 additions and 5 deletions
+12 -5
View File
@@ -1,9 +1,8 @@
use actix_web::{HttpResponse, get};
use serde_json::json;
#[get("/")]
pub async fn index_get() -> HttpResponse {
let data = json!({
fn build_info() -> serde_json::Value {
json!({
"name": "modrinth-labrinth",
"version": env!("CARGO_PKG_VERSION"),
"documentation": "https://docs.modrinth.com",
@@ -14,7 +13,15 @@ pub async fn index_get() -> HttpResponse {
"git_hash": option_env!("GIT_HASH").unwrap_or("unknown"),
"profile": env!("COMPILATION_PROFILE"),
}
});
})
}
HttpResponse::Ok().json(data)
#[get("/")]
pub async fn index_get() -> HttpResponse {
HttpResponse::Ok().json(build_info())
}
#[get("/build")]
pub async fn build_get() -> HttpResponse {
HttpResponse::Ok().json(build_info())
}
+1
View File
@@ -138,6 +138,7 @@ pub fn root_config(cfg: &mut web::ServiceConfig) {
web::scope("")
.wrap(default_cors())
.service(index::index_get)
.service(index::build_get)
.service(Files::new("/", "assets/")),
);
}