[pbs-devel] [PATCH proxmox-backup v2 13/16] move src/server/rest.rs to proxmox-rest-server crate
Dietmar Maurer
dietmar at proxmox.com
Tue Sep 21 07:58:51 CEST 2021
---
proxmox-rest-server/Cargo.toml | 4 ++++
proxmox-rest-server/src/lib.rs | 3 +++
{src/server => proxmox-rest-server/src}/rest.rs | 6 +++---
src/bin/proxmox-backup-api.rs | 3 +--
src/bin/proxmox-backup-proxy.rs | 3 +--
src/bin/proxmox-restore-daemon.rs | 4 +---
src/server/h2service.rs | 2 +-
src/server/mod.rs | 3 ---
8 files changed, 14 insertions(+), 14 deletions(-)
rename {src/server => proxmox-rest-server/src}/rest.rs (99%)
diff --git a/proxmox-rest-server/Cargo.toml b/proxmox-rest-server/Cargo.toml
index c19dfb0b..2f740e67 100644
--- a/proxmox-rest-server/Cargo.toml
+++ b/proxmox-rest-server/Cargo.toml
@@ -16,9 +16,13 @@ libc = "0.2"
log = "0.4"
nix = "0.19.1"
percent-encoding = "2.1"
+regex = "1.2"
serde = { version = "1.0", features = [] }
serde_json = "1.0"
tokio = { version = "1.6", features = ["signal", "process"] }
+tokio-openssl = "0.6.1"
+tower-service = "0.3.0"
+url = "2.1"
proxmox = { version = "0.13.3", features = [ "router"] }
diff --git a/proxmox-rest-server/src/lib.rs b/proxmox-rest-server/src/lib.rs
index 55a10ca6..2f29f9cd 100644
--- a/proxmox-rest-server/src/lib.rs
+++ b/proxmox-rest-server/src/lib.rs
@@ -26,6 +26,9 @@ pub use file_logger::{FileLogger, FileLogOptions};
mod api_config;
pub use api_config::ApiConfig;
+mod rest;
+pub use rest::{RestServer, handle_api_request};
+
pub enum AuthError {
Generic(Error),
NoData,
diff --git a/src/server/rest.rs b/proxmox-rest-server/src/rest.rs
similarity index 99%
rename from src/server/rest.rs
rename to proxmox-rest-server/src/rest.rs
index 59fbb396..dde47b55 100644
--- a/src/server/rest.rs
+++ b/proxmox-rest-server/src/rest.rs
@@ -32,11 +32,11 @@ use proxmox::http_err;
use pbs_tools::compression::{DeflateEncoder, Level};
use pbs_tools::stream::AsyncReaderStream;
-use proxmox_rest_server::{
+
+use crate::{
ApiConfig, FileLogger, AuthError, RestEnvironment, CompressionMethod,
- extract_cookie, normalize_uri_path,
+ extract_cookie, normalize_uri_path, formatter::*,
};
-use proxmox_rest_server::formatter::*;
extern "C" {
fn tzset();
diff --git a/src/bin/proxmox-backup-api.rs b/src/bin/proxmox-backup-api.rs
index 7653f412..9ad10260 100644
--- a/src/bin/proxmox-backup-api.rs
+++ b/src/bin/proxmox-backup-api.rs
@@ -10,12 +10,11 @@ use proxmox::api::RpcEnvironmentType;
use proxmox::tools::fs::CreateOptions;
use pbs_tools::auth::private_auth_key;
-use proxmox_rest_server::ApiConfig;
+use proxmox_rest_server::{ApiConfig, RestServer};
use proxmox_backup::server::{
self,
auth::default_api_auth,
- rest::*,
};
use proxmox_rest_server::daemon;
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index 5679de43..6a8736e2 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -19,14 +19,13 @@ use proxmox::api::RpcEnvironmentType;
use proxmox::sys::linux::socket::set_tcp_keepalive;
use proxmox::tools::fs::CreateOptions;
-use proxmox_rest_server::ApiConfig;
+use proxmox_rest_server::{ApiConfig, RestServer};
use proxmox_backup::{
backup::DataStore,
server::{
auth::default_api_auth,
WorkerTask,
- rest::*,
jobstate::{
self,
Job,
diff --git a/src/bin/proxmox-restore-daemon.rs b/src/bin/proxmox-restore-daemon.rs
index d9a8eff0..9cf7f755 100644
--- a/src/bin/proxmox-restore-daemon.rs
+++ b/src/bin/proxmox-restore-daemon.rs
@@ -21,9 +21,7 @@ use hyper::header;
use proxmox::api::RpcEnvironmentType;
use pbs_client::DEFAULT_VSOCK_PORT;
-use proxmox_rest_server::ApiConfig;
-
-use proxmox_backup::server::rest::*;
+use proxmox_rest_server::{ApiConfig, RestServer};
mod proxmox_restore_daemon;
use proxmox_restore_daemon::*;
diff --git a/src/server/h2service.rs b/src/server/h2service.rs
index 4e3024aa..41d628be 100644
--- a/src/server/h2service.rs
+++ b/src/server/h2service.rs
@@ -61,7 +61,7 @@ impl <E: RpcEnvironment + Clone> H2Service<E> {
future::ok((formatter.format_error)(err)).boxed()
}
Some(api_method) => {
- crate::server::rest::handle_api_request(
+ proxmox_rest_server::handle_api_request(
self.rpcenv.clone(), api_method, formatter, parts, body, uri_param).boxed()
}
}
diff --git a/src/server/mod.rs b/src/server/mod.rs
index 1fc57575..a7dcee67 100644
--- a/src/server/mod.rs
+++ b/src/server/mod.rs
@@ -55,9 +55,6 @@ pub use worker_task::*;
mod h2service;
pub use h2service::*;
-#[macro_use]
-pub mod rest;
-
pub mod jobstate;
mod verify_job;
--
2.30.2
More information about the pbs-devel
mailing list