diff --git a/src/api_schema/config.rs b/src/api_schema/config.rs index e8ac4a4c..77bc528c 100644 --- a/src/api_schema/config.rs +++ b/src/api_schema/config.rs @@ -25,16 +25,7 @@ impl ApiConfig { pub fn find_method(&self, components: &[&str], method: Method, uri_param: &mut HashMap) -> &'static MethodDefinition { - if let Some(info) = self.router.find_route(components, uri_param) { - return match method { - Method::GET => &info.get, - Method::PUT => &info.put, - Method::POST => &info.post, - Method::DELETE => &info.delete, - _ => &MethodDefinition::None, - }; - } - &MethodDefinition::None + self.router.find_method(components, method, uri_param) } pub fn find_alias(&self, components: &[&str]) -> PathBuf { diff --git a/src/api_schema/router.rs b/src/api_schema/router.rs index 834b46d9..a2605e19 100644 --- a/src/api_schema/router.rs +++ b/src/api_schema/router.rs @@ -6,7 +6,7 @@ use std::collections::HashMap; use std::sync::Arc; use std::fmt; -use hyper::{Body, Response, StatusCode}; +use hyper::{Body, Method, Response, StatusCode}; use hyper::rt::Future; use hyper::http::request::Parts; @@ -305,4 +305,23 @@ impl Router { None } + + pub fn find_method( + &self, + components: &[&str], + method: Method, + uri_param: &mut HashMap + ) -> &MethodDefinition { + + if let Some(info) = self.find_route(components, uri_param) { + return match method { + Method::GET => &info.get, + Method::PUT => &info.put, + Method::POST => &info.post, + Method::DELETE => &info.delete, + _ => &MethodDefinition::None, + }; + } + &MethodDefinition::None + } }