diff --git a/f9/src/app.rs b/f9/src/app.rs index 10af5ff..d6ec573 100644 --- a/f9/src/app.rs +++ b/f9/src/app.rs @@ -49,7 +49,7 @@ pub struct App { im_msgs: Rc::>>, im_work_msgs: Rc::>>, im_mutex: Mutex, - http_handlers: HashMap>, + http_handlers: HashMap>>, webapp_state: Arc::, } @@ -248,15 +248,17 @@ impl App { let ctx = &mut req.lock().unwrap(); let ca = web::Query::::from_query(&ctx.query_str).unwrap(); let key = format!("{}${}", &ca.c, &ca.a); - match &mut App::instance().borrow_mut().get_http_handle(&key) { + let h = App::instance().borrow_mut().get_http_handle(&key); + match h { Some(handle) => { - (handle)(ctx); + (handle.borrow_mut())(ctx); ctx.handled = true; } None => { - //ctx.handled = true; + ctx.rsp = "not implement".to_string(); + ctx.handled = true; } - } + }; } } None => { @@ -276,10 +278,10 @@ impl App { } fn get_http_handle(&mut self, key: &String) -> - Option<&mut Box::> { - match self.http_handlers.get_mut(key) { + Option>> { + match self.http_handlers.get(key) { Some(v) => { - return Some(v); + return Some(v.clone()); } None => { return None; @@ -299,7 +301,7 @@ impl App { } pub fn add_http_handler(&mut self, key: String, - cb: Box::) { + cb: Rc::>) { self.http_handlers.insert(key, cb); }