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_msgs: Rc::<RefCell::<r9::ListHead::<IMMsgNode>>>,
|
||||||
im_work_msgs: Rc::<RefCell::<r9::ListHead::<IMMsgNode>>>,
|
im_work_msgs: Rc::<RefCell::<r9::ListHead::<IMMsgNode>>>,
|
||||||
im_mutex: Mutex<i32>,
|
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>,
|
webapp_state: Arc::<AppState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,15 +248,17 @@ impl App {
|
|||||||
let ctx = &mut req.lock().unwrap();
|
let ctx = &mut req.lock().unwrap();
|
||||||
let ca = web::Query::<Ca>::from_query(&ctx.query_str).unwrap();
|
let ca = web::Query::<Ca>::from_query(&ctx.query_str).unwrap();
|
||||||
let key = format!("{}${}", &ca.c, &ca.a);
|
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) => {
|
Some(handle) => {
|
||||||
(handle)(ctx);
|
(handle.borrow_mut())(ctx);
|
||||||
ctx.handled = true;
|
ctx.handled = true;
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
//ctx.handled = true;
|
ctx.rsp = "not implement".to_string();
|
||||||
|
ctx.handled = true;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
@ -276,10 +278,10 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_http_handle(&mut self, key: &String) ->
|
fn get_http_handle(&mut self, key: &String) ->
|
||||||
Option<&mut Box::<dyn FnMut (&mut HttpContext)>> {
|
Option<Rc::<RefCell::<dyn FnMut (&mut HttpContext)>>> {
|
||||||
match self.http_handlers.get_mut(key) {
|
match self.http_handlers.get(key) {
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
return Some(v);
|
return Some(v.clone());
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
return None;
|
return None;
|
||||||
@ -299,7 +301,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_http_handler(&mut self, key: String,
|
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);
|
self.http_handlers.insert(key, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user