feat(connection): add reusable tunnel profiles

This commit is contained in:
rainhan authored and GitHub committed 2026-07-12 22:03:46 +08:00
1 parent 4dcee1aca0
commit 977e7f78ca
34 files changed
+1335 -22

No files matched your search

+1
View File
@@ -30,5 +30,6 @@ pub mod table_export;
pub mod table_import;
pub mod text_export;
pub mod transfer;
pub mod tunnel_profiles;
pub mod update;
pub mod zookeeper;
@@ -0,0 +1,28 @@
use std::sync::Arc;
use axum::extract::State;
use axum::Json;
use dbx_core::models::connection::TransportLayerConfig;
use serde::Deserialize;
use crate::error::AppError;
use crate::state::WebState;
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SaveTunnelProfilesRequest {
pub profiles: Vec<TransportLayerConfig>,
}
pub async fn load_tunnel_profiles(
State(state): State<Arc<WebState>>,
) -> Result<Json<Vec<TransportLayerConfig>>, AppError> {
state.app.storage.load_tunnel_profiles().await.map(Json).map_err(AppError)
}
pub async fn save_tunnel_profiles(
State(state): State<Arc<WebState>>,
Json(body): Json<SaveTunnelProfilesRequest>,
) -> Result<Json<()>, AppError> {
state.app.storage.save_tunnel_profiles(&body.profiles).await.map(Json).map_err(AppError)
}