-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 提供备份数据http接口,以支持通过外部定时脚本发起定时备份功能; #172
- Loading branch information
Showing
7 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use crate::common::appdata::AppShareData; | ||
use crate::console::transfer_api::download_transfer_file; | ||
use actix_web::{web, HttpResponse, Responder}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::sync::Arc; | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct BackupParam { | ||
pub token: Arc<String>, | ||
} | ||
|
||
pub async fn backup( | ||
app_share_data: web::Data<Arc<AppShareData>>, | ||
web::Query(params): web::Query<BackupParam>, | ||
) -> impl Responder { | ||
if app_share_data.sys_config.backup_token.is_empty() { | ||
HttpResponse::InternalServerError().body("backup api is not open") | ||
} else if params.token.as_str() != app_share_data.sys_config.backup_token.as_str() { | ||
HttpResponse::InternalServerError().body("backup token is not matched") | ||
} else { | ||
download_transfer_file(app_share_data).await | ||
} | ||
} | ||
|
||
pub fn backup_config(config: &mut web::ServiceConfig) { | ||
config.service(web::resource("/rnacos/backup").route(web::get().to(backup))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters