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.",
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,
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 {
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); };
#[macro_export]
macro_rules! methodinfo {
($($option:ident => $e:expr),*) => {{
- let info = MethodInfo::new();
+ let info = Router::new();
$(
info.$option = Some($e);
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);