feat(http_server): add app-version endpoint
This commit is contained in:
parent
fd0fc47ccf
commit
283c4ebad2
6 changed files with 256 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ kernel = { path = "../kernel" }
|
|||
utils = { path = "../utils" }
|
||||
|
||||
# common
|
||||
shadow-rs = { workspace = true }
|
||||
log = { workspace = true }
|
||||
env_logger = { workspace = true }
|
||||
|
||||
|
|
@ -54,6 +55,7 @@ branch = "master"
|
|||
features = ["simple_asn1", "pem"]
|
||||
|
||||
[build-dependencies]
|
||||
shadow-rs = { workspace = true }
|
||||
minijinja-embed = "2.3.1"
|
||||
|
||||
[[bin]]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
use shadow_rs::ShadowBuilder;
|
||||
|
||||
fn main() {
|
||||
ShadowBuilder::builder().build().unwrap();
|
||||
minijinja_embed::embed_templates!("src/templates");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
use axum::{extract::State, response::IntoResponse, Json};
|
||||
use serde_json::json;
|
||||
use shadow_rs::shadow;
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
shadow!(build);
|
||||
|
||||
pub async fn get_index(
|
||||
State(app_state): State<AppState>,
|
||||
) -> impl IntoResponse {
|
||||
|
|
@ -12,3 +15,11 @@ pub async fn get_index(
|
|||
"base_uri": app_state.config.instance.base_uri
|
||||
}))
|
||||
}
|
||||
|
||||
pub async fn get_app_version() -> impl IntoResponse {
|
||||
Json(json!({
|
||||
"tag": shadow_rs::tag(),
|
||||
"branch": shadow_rs::branch(),
|
||||
"commit_hash": build::COMMIT_HASH
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ pub fn build_router(server_config: &ServerConfig, app_state: AppState) -> Router
|
|||
let public_api_routes = Router::new()
|
||||
.route("/api", get(api::index::get_index))
|
||||
.route("/api/user-assets/{asset_id}", get(api::public_assets::get_user_asset))
|
||||
.route("/.app-version", get(api::index::get_app_version))
|
||||
.route("/.well-known/openid-configuration", get(api::openid::well_known::get_well_known_openid_configuration))
|
||||
.route("/.well-known/jwks", get(api::openid::keys::get_signing_public_keys));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue