//! hierarchy of API entries, and provides ways to find an API
//! definition by path.
-pub mod config;
pub mod format;
+++ /dev/null
-use std::collections::HashMap;
-use std::path::{PathBuf};
-
-use hyper::Method;
-
-use proxmox::api::{ApiMethod, Router, RpcEnvironmentType};
-
-pub struct ApiConfig {
- basedir: PathBuf,
- router: &'static Router,
- aliases: HashMap<String, PathBuf>,
- env_type: RpcEnvironmentType,
-}
-
-impl ApiConfig {
-
- pub fn new<B: Into<PathBuf>>(basedir: B, router: &'static Router, env_type: RpcEnvironmentType) -> Self {
- Self {
- basedir: basedir.into(),
- router,
- aliases: HashMap::new(),
- env_type,
- }
- }
-
- pub fn find_method(
- &self,
- components: &[&str],
- method: Method,
- uri_param: &mut HashMap<String, String>,
- ) -> Option<&'static ApiMethod> {
-
- self.router.find_method(components, method, uri_param)
- }
-
- pub fn find_alias(&self, components: &[&str]) -> PathBuf {
-
- let mut prefix = String::new();
- let mut filename = self.basedir.clone();
- let comp_len = components.len();
- if comp_len >= 1 {
- prefix.push_str(components[0]);
- if let Some(subdir) = self.aliases.get(&prefix) {
- filename.push(subdir);
- for i in 1..comp_len { filename.push(components[i]) }
- } else {
- for i in 0..comp_len { filename.push(components[i]) }
- }
- }
- filename
- }
-
- pub fn add_alias<S, P>(&mut self, alias: S, path: P)
- where S: Into<String>,
- P: Into<PathBuf>,
- {
- self.aliases.insert(alias.into(), path.into());
- }
-
- pub fn env_type(&self) -> RpcEnvironmentType {
- self.env_type
- }
-}
use proxmox::api::RpcEnvironmentType;
//use proxmox_backup::tools;
-use proxmox_backup::api_schema::config::*;
+//use proxmox_backup::api_schema::config::*;
use proxmox_backup::server::rest::*;
use proxmox_backup::server;
use proxmox_backup::tools::daemon;
}
let _ = csrf_secret(); // load with lazy_static
- let config = ApiConfig::new(
+ let config = server::ApiConfig::new(
buildcfg::JS_DIR, &proxmox_backup::api2::ROUTER, RpcEnvironmentType::PRIVILEGED);
let rest_server = RestServer::new(config);
use proxmox_backup::buildcfg;
use proxmox_backup::server;
use proxmox_backup::tools::daemon;
-use proxmox_backup::api_schema::config::*;
-use proxmox_backup::server::rest::*;
+use proxmox_backup::server::{ApiConfig, rest::*};
use proxmox_backup::auth_helpers::*;
#[tokio::main]
mod h2service;
pub use h2service::*;
+pub mod config;
+pub use config::*;
+
pub mod formatter;
#[macro_use]
--- /dev/null
+use std::collections::HashMap;
+use std::path::{PathBuf};
+
+use hyper::Method;
+
+use proxmox::api::{ApiMethod, Router, RpcEnvironmentType};
+
+pub struct ApiConfig {
+ basedir: PathBuf,
+ router: &'static Router,
+ aliases: HashMap<String, PathBuf>,
+ env_type: RpcEnvironmentType,
+}
+
+impl ApiConfig {
+
+ pub fn new<B: Into<PathBuf>>(basedir: B, router: &'static Router, env_type: RpcEnvironmentType) -> Self {
+ Self {
+ basedir: basedir.into(),
+ router,
+ aliases: HashMap::new(),
+ env_type,
+ }
+ }
+
+ pub fn find_method(
+ &self,
+ components: &[&str],
+ method: Method,
+ uri_param: &mut HashMap<String, String>,
+ ) -> Option<&'static ApiMethod> {
+
+ self.router.find_method(components, method, uri_param)
+ }
+
+ pub fn find_alias(&self, components: &[&str]) -> PathBuf {
+
+ let mut prefix = String::new();
+ let mut filename = self.basedir.clone();
+ let comp_len = components.len();
+ if comp_len >= 1 {
+ prefix.push_str(components[0]);
+ if let Some(subdir) = self.aliases.get(&prefix) {
+ filename.push(subdir);
+ for i in 1..comp_len { filename.push(components[i]) }
+ } else {
+ for i in 0..comp_len { filename.push(components[i]) }
+ }
+ }
+ filename
+ }
+
+ pub fn add_alias<S, P>(&mut self, alias: S, path: P)
+ where S: Into<String>,
+ P: Into<PathBuf>,
+ {
+ self.aliases.insert(alias.into(), path.into());
+ }
+
+ pub fn env_type(&self) -> RpcEnvironmentType {
+ self.env_type
+ }
+}
use super::environment::RestEnvironment;
use super::formatter::*;
+use super::ApiConfig;
+
use crate::auth_helpers::*;
-use crate::api_schema::config::ApiConfig;
use crate::tools;
extern "C" { fn tzset(); }