From f7348a23cd80671a0e86110b64d0523b5be13ac3 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 23 Sep 2021 12:38:09 +0200 Subject: [PATCH] move src/server/h2service.rs into proxmox-rest-server crate --- {src/server => proxmox-rest-server/src}/h2service.rs | 6 +++--- proxmox-rest-server/src/lib.rs | 5 ++++- proxmox-rest-server/src/rest.rs | 2 +- src/api2/backup/mod.rs | 3 +-- src/api2/reader/mod.rs | 10 ++-------- src/server/mod.rs | 3 --- 6 files changed, 11 insertions(+), 18 deletions(-) rename {src/server => proxmox-rest-server/src}/h2service.rs (96%) diff --git a/src/server/h2service.rs b/proxmox-rest-server/src/h2service.rs similarity index 96% rename from src/server/h2service.rs rename to proxmox-rest-server/src/h2service.rs index 0b51a710..f5556d1a 100644 --- a/src/server/h2service.rs +++ b/proxmox-rest-server/src/h2service.rs @@ -11,8 +11,8 @@ use hyper::{Body, Request, Response, StatusCode}; use proxmox::api::{ApiResponseFuture, HttpError, Router, RpcEnvironment}; use proxmox::http_err; -use proxmox_rest_server::{normalize_uri_path, WorkerTask}; -use proxmox_rest_server::formatter::*; +use crate::{normalize_uri_path, WorkerTask}; +use crate::formatter::*; /// Hyper Service implementation to handle stateful H2 connections. /// @@ -59,7 +59,7 @@ impl H2Service { future::ok((formatter.format_error)(err)).boxed() } Some(api_method) => { - proxmox_rest_server::handle_api_request( + crate::rest::handle_api_request( self.rpcenv.clone(), api_method, formatter, parts, body, uri_param).boxed() } } diff --git a/proxmox-rest-server/src/lib.rs b/proxmox-rest-server/src/lib.rs index 9acdb3fd..5ba72ce0 100644 --- a/proxmox-rest-server/src/lib.rs +++ b/proxmox-rest-server/src/lib.rs @@ -30,11 +30,14 @@ mod api_config; pub use api_config::ApiConfig; mod rest; -pub use rest::{RestServer, handle_api_request}; +pub use rest::RestServer; mod worker_task; pub use worker_task::*; +mod h2service; +pub use h2service::*; + pub enum AuthError { Generic(Error), NoData, diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs index dde47b55..929e4043 100644 --- a/proxmox-rest-server/src/rest.rs +++ b/proxmox-rest-server/src/rest.rs @@ -388,7 +388,7 @@ async fn proxy_protected_request( Ok(resp) } -pub async fn handle_api_request( +pub(crate) async fn handle_api_request( mut rpcenv: Env, info: &'static ApiMethod, formatter: &'static OutputFormatter, diff --git a/src/api2/backup/mod.rs b/src/api2/backup/mod.rs index 4333be17..d9ad95de 100644 --- a/src/api2/backup/mod.rs +++ b/src/api2/backup/mod.rs @@ -23,9 +23,8 @@ use pbs_datastore::PROXMOX_BACKUP_PROTOCOL_ID_V1; use pbs_datastore::backup_info::{BackupDir, BackupGroup, BackupInfo}; use pbs_datastore::index::IndexFile; use pbs_datastore::manifest::{archive_type, ArchiveType}; -use proxmox_rest_server::WorkerTask; +use proxmox_rest_server::{WorkerTask, H2Service}; -use crate::server::H2Service; use crate::backup::DataStore; use pbs_config::CachedUserInfo; diff --git a/src/api2/reader/mod.rs b/src/api2/reader/mod.rs index c663e9ae..e451a596 100644 --- a/src/api2/reader/mod.rs +++ b/src/api2/reader/mod.rs @@ -39,15 +39,9 @@ use pbs_datastore::backup_info::BackupDir; use pbs_datastore::index::IndexFile; use pbs_datastore::manifest::{archive_type, ArchiveType}; use pbs_config::CachedUserInfo; -use proxmox_rest_server::WorkerTask; +use proxmox_rest_server::{WorkerTask, H2Service}; -use crate::{ - api2::helpers, - backup::DataStore, - server::{ - H2Service, - }, -}; +use crate::{api2::helpers, backup::DataStore}; mod environment; use environment::*; diff --git a/src/server/mod.rs b/src/server/mod.rs index 96d57bd4..a6574631 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -11,9 +11,6 @@ use proxmox::tools::fs::{create_path, CreateOptions}; use pbs_buildcfg; -mod h2service; -pub use h2service::*; - pub mod jobstate; mod verify_job;