feat: 迁移所有配置到数据库,并支持运行时重载 (#364)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2025-06-17 02:15:11 +08:00
committed by GitHub
parent a46c2572b1
commit 4539e9379d
46 changed files with 1055 additions and 715 deletions

View File

@@ -7,10 +7,12 @@ use utoipa::Modify;
use utoipa::openapi::security::{ApiKey, ApiKeyValue, SecurityScheme};
use crate::api::wrapper::ApiResponse;
use crate::config::CONFIG;
use crate::config::VersionedConfig;
pub async fn auth(headers: HeaderMap, request: Request, next: Next) -> Result<Response, StatusCode> {
if request.uri().path().starts_with("/api/") && get_token(&headers) != CONFIG.auth_token {
if request.uri().path().starts_with("/api/")
&& get_token(&headers).is_none_or(|token| token != VersionedConfig::get().load().auth_token)
{
return Ok(ApiResponse::unauthorized(()).into_response());
}
Ok(next.run(request).await)