move find_method to Router class
This commit is contained in:
parent
3578d99f3e
commit
01bf3b7b5f
@ -25,16 +25,7 @@ impl ApiConfig {
|
||||
|
||||
pub fn find_method(&self, components: &[&str], method: Method, uri_param: &mut HashMap<String, String>) -> &'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 {
|
||||
|
@ -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<String, String>
|
||||
) -> &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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user