mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-06-07 00:29:51 +08:00
feat: 加入重置单个视频状态的 API,视频接口返回下载状态 (#258)
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
use axum::extract::Request;
|
||||
use axum::http::HeaderMap;
|
||||
use axum::middleware::Next;
|
||||
use axum::response::Response;
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use reqwest::StatusCode;
|
||||
use utoipa::openapi::security::{ApiKey, ApiKeyValue, SecurityScheme};
|
||||
use utoipa::Modify;
|
||||
|
||||
use crate::api::wrapper::ApiResponse;
|
||||
use crate::config::CONFIG;
|
||||
|
||||
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 {
|
||||
return Err(StatusCode::UNAUTHORIZED);
|
||||
return Ok(ApiResponse::unauthorized(()).into_response());
|
||||
}
|
||||
Ok(next.run(request).await)
|
||||
}
|
||||
@@ -22,7 +23,7 @@ fn get_token(headers: &HeaderMap) -> Option<String> {
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
pub struct OpenAPIAuth;
|
||||
pub(super) struct OpenAPIAuth;
|
||||
|
||||
impl Modify for OpenAPIAuth {
|
||||
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
|
||||
|
||||
Reference in New Issue
Block a user