From e63e99d64602270aeccd9f09976f22b89f5d9118 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 15 Nov 2018 11:46:13 +0100 Subject: [PATCH] rename MethodInfo to Router --- src/api3.rs | 4 ++-- src/api_config.rs | 4 ++-- src/api_info.rs | 10 +++++----- src/main.rs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/api3.rs b/src/api3.rs index 40789ace..20179476 100644 --- a/src/api3.rs +++ b/src/api3.rs @@ -24,9 +24,9 @@ fn test_sync_api_handler(param: Value, _info: &ApiMethod) -> Result 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.", diff --git a/src/api_config.rs b/src/api_config.rs index 850a89e8..db9cec92 100644 --- a/src/api_config.rs +++ b/src/api_config.rs @@ -8,13 +8,13 @@ use hyper::Method; pub struct ApiConfig { basedir: PathBuf, - router: &'static MethodInfo, + router: &'static Router, aliases: HashMap, } impl ApiConfig { - pub fn new>(basedir: B, router: &'static MethodInfo) -> Self { + pub fn new>(basedir: B, router: &'static Router) -> Self { Self { basedir: basedir.into(), router: router, diff --git a/src/api_info.rs b/src/api_info.rs index ee4de13d..f2ee1c6d 100644 --- a/src/api_info.rs +++ b/src/api_info.rs @@ -11,15 +11,15 @@ pub struct ApiMethod { pub handler: fn(Value, &ApiMethod) -> Result, } -pub struct MethodInfo { +pub struct Router { pub get: Option, pub put: Option, pub post: Option, pub delete: Option, - pub subdirs: Option>, + pub subdirs: Option>, } -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); diff --git a/src/main.rs b/src/main.rs index 9315c844..07287dcc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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);