mirror of
https://github.com/modrinth/code.git
synced 2026-08-27 01:54:47 +00:00
feat: add /build route (#6644)
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
use actix_web::{HttpResponse, get};
|
use actix_web::{HttpResponse, get};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
#[get("/")]
|
fn build_info() -> serde_json::Value {
|
||||||
pub async fn index_get() -> HttpResponse {
|
json!({
|
||||||
let data = json!({
|
|
||||||
"name": "modrinth-labrinth",
|
"name": "modrinth-labrinth",
|
||||||
"version": env!("CARGO_PKG_VERSION"),
|
"version": env!("CARGO_PKG_VERSION"),
|
||||||
"documentation": "https://docs.modrinth.com",
|
"documentation": "https://docs.modrinth.com",
|
||||||
@@ -14,7 +13,15 @@ pub async fn index_get() -> HttpResponse {
|
|||||||
"git_hash": option_env!("GIT_HASH").unwrap_or("unknown"),
|
"git_hash": option_env!("GIT_HASH").unwrap_or("unknown"),
|
||||||
"profile": env!("COMPILATION_PROFILE"),
|
"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())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ pub fn root_config(cfg: &mut web::ServiceConfig) {
|
|||||||
web::scope("")
|
web::scope("")
|
||||||
.wrap(default_cors())
|
.wrap(default_cors())
|
||||||
.service(index::index_get)
|
.service(index::index_get)
|
||||||
|
.service(index::build_get)
|
||||||
.service(Files::new("/", "assets/")),
|
.service(Files::new("/", "assets/")),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user