1
This commit is contained in:
parent
dea499028d
commit
5ad5aa0c27
@ -49,7 +49,7 @@ pub struct App {
|
||||
im_msgs: Rc::<RefCell::<r9::ListHead::<IMMsgNode>>>,
|
||||
im_work_msgs: Rc::<RefCell::<r9::ListHead::<IMMsgNode>>>,
|
||||
im_mutex: Mutex<i32>,
|
||||
http_handlers: HashMap<String, Box::<dyn FnMut (&mut HttpContext)>>,
|
||||
http_handlers: HashMap<String, Rc::<RefCell::<dyn FnMut (&mut HttpContext)>>>,
|
||||
webapp_state: Arc::<AppState>,
|
||||
}
|
||||
|
||||
@ -248,15 +248,17 @@ impl App {
|
||||
let ctx = &mut req.lock().unwrap();
|
||||
let ca = web::Query::<Ca>::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::<dyn FnMut (&mut HttpContext)>> {
|
||||
match self.http_handlers.get_mut(key) {
|
||||
Option<Rc::<RefCell::<dyn FnMut (&mut HttpContext)>>> {
|
||||
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::<dyn FnMut (&mut HttpContext)>) {
|
||||
cb: Rc::<RefCell::<dyn FnMut (&mut HttpContext)>>) {
|
||||
self.http_handlers.insert(key, cb);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user