]> git.proxmox.com Git - proxmox-backup.git/commitdiff
rename MethodInfo to Router
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 15 Nov 2018 10:46:13 +0000 (11:46 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 15 Nov 2018 10:46:13 +0000 (11:46 +0100)
src/api3.rs
src/api_config.rs
src/api_info.rs
src/main.rs

index 40789aced5e13c06c2a230fd7a037941f6b9b0ed..201794764d0944c15111ef643079ae2dfae2e634 100644 (file)
@@ -24,9 +24,9 @@ fn test_sync_api_handler(param: Value, _info: &ApiMethod) -> Result<Value, Error
     Ok(json!(null))
 }
 
-pub fn router() -> MethodInfo {
+pub fn router() -> Router {
 
-    let route = MethodInfo::new()
+    let route = Router::new()
         .get(ApiMethod {
             handler: test_sync_api_handler,
             description: "This is a simple test.",
index 850a89e8d84d9db4a3543f8966365fab508051e6..db9cec92952e18e61fbb97f44b4ec68db9601db5 100644 (file)
@@ -8,13 +8,13 @@ use hyper::Method;
 
 pub struct ApiConfig {
     basedir: PathBuf,
-    router: &'static MethodInfo,
+    router: &'static Router,
     aliases: HashMap<String, PathBuf>,
 }
 
 impl ApiConfig {
 
-    pub fn new<B: Into<PathBuf>>(basedir: B, router: &'static MethodInfo) -> Self {
+    pub fn new<B: Into<PathBuf>>(basedir: B, router: &'static Router) -> Self {
         Self {
             basedir: basedir.into(),
             router: router,
index ee4de13df4368d6db697e9a359559d078d78cb77..f2ee1c6d96b2ad60c1f7e012d31b7a81a2a9fc9b 100644 (file)
@@ -11,15 +11,15 @@ pub struct ApiMethod {
     pub handler: fn(Value, &ApiMethod) -> Result<Value, Error>,
 }
 
-pub struct MethodInfo {
+pub struct Router {
     pub get: Option<ApiMethod>,
     pub put: Option<ApiMethod>,
     pub post: Option<ApiMethod>,
     pub delete: Option<ApiMethod>,
-    pub subdirs: Option<HashMap<String, MethodInfo>>,
+    pub subdirs: Option<HashMap<String, Router>>,
 }
 
-impl MethodInfo {
+impl Router {
 
     pub fn new() -> Self {
         Self {
@@ -36,7 +36,7 @@ impl MethodInfo {
         self
     }
 
-    pub fn find_route(&self, components: &[&str]) -> Option<&MethodInfo> {
+    pub fn find_route(&self, components: &[&str]) -> Option<&Router> {
 
         if components.len() == 0 { return Some(self); };
 
@@ -56,7 +56,7 @@ impl MethodInfo {
 #[macro_export]
 macro_rules! methodinfo {
     ($($option:ident => $e:expr),*) => {{
-        let info = MethodInfo::new();
+        let info = Router::new();
 
         $(
             info.$option = Some($e);
index 9315c8445c0c71358a19eec62a4cf2c48865ae76..07287dcc651944cd0962be104009e2891bbe7c03 100644 (file)
@@ -17,7 +17,7 @@ fn main() {
     let addr = ([127, 0, 0, 1], 8007).into();
 
     lazy_static!{
-       static ref ROUTER: MethodInfo = apitest::api3::router();
+       static ref ROUTER: Router = apitest::api3::router();
     }
 
     let mut config = ApiConfig::new("/var/www", &ROUTER);