Remove LazyLock (incompatible with older Rusts)

This commit is contained in:
Igor Katson 2025-01-14 11:27:14 +00:00
parent c60f36540e
commit 2c85624ec2
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5

View file

@ -6,7 +6,7 @@ mod playlist;
mod streaming; mod streaming;
mod torrents; mod torrents;
use std::sync::{Arc, LazyLock}; use std::sync::Arc;
use axum::{ use axum::{
response::{IntoResponse, Redirect}, response::{IntoResponse, Redirect},
@ -32,8 +32,7 @@ async fn h_api_root(parts: Parts) -> impl IntoResponse {
} }
} }
static API_ROOT_JSON: LazyLock<Arc<serde_json::Value>> = LazyLock::new(|| { let json = serde_json::json!({
Arc::new(serde_json::json!({
"apis": { "apis": {
"GET /": "list all available APIs", "GET /": "list all available APIs",
"GET /dht/stats": "DHT stats", "GET /dht/stats": "DHT stats",
@ -59,14 +58,9 @@ async fn h_api_root(parts: Parts) -> impl IntoResponse {
}, },
"server": "rqbit", "server": "rqbit",
"version": env!("CARGO_PKG_VERSION"), "version": env!("CARGO_PKG_VERSION"),
}))
}); });
( ([("Content-Type", "application/json")], axum::Json(json)).into_response()
[("Content-Type", "application/json")],
axum::Json(API_ROOT_JSON.clone()),
)
.into_response()
} }
pub fn make_api_router(state: ApiState) -> Router { pub fn make_api_router(state: ApiState) -> Router {