64 lines
1.3 KiB
Rust
64 lines
1.3 KiB
Rust
use std::rc::{Rc, Weak};
|
|
use std::cell::RefCell;
|
|
use r9_macro::SharedFromSelf;
|
|
use r9_macro_derive::SharedFromSelf;
|
|
use r9_macro_derive::Singleton;
|
|
use f9::app::App;
|
|
use f9::app::HttpContext;
|
|
|
|
#[derive(SharedFromSelf)]
|
|
#[derive(Singleton)]
|
|
pub struct UserApp {
|
|
_self_wp: Weak::<RefCell::<Self>>,
|
|
}
|
|
|
|
impl f9::app::UserApp for UserApp {
|
|
|
|
fn get_pkg_name(&self) -> String {
|
|
return "statserver".to_string();
|
|
}
|
|
|
|
fn init(&mut self) {
|
|
App::instance().borrow_mut().add_http_handler(
|
|
"Ops$selfChecking".to_string(),
|
|
Box::new(
|
|
move |ctx: &mut HttpContext| {
|
|
ctx.rsp = "Ops$selfChecking".to_string();
|
|
}
|
|
),
|
|
);
|
|
App::instance().borrow_mut().add_http_handler(
|
|
"Ops$selfChecking1".to_string(),
|
|
Box::new(
|
|
move |ctx: &mut HttpContext| {
|
|
ctx.rsp = "Ops$selfChecking1".to_string();
|
|
}
|
|
),
|
|
);
|
|
}
|
|
|
|
fn update(&mut self) {
|
|
|
|
}
|
|
|
|
fn uninit(&mut self) {
|
|
|
|
}
|
|
|
|
fn get_http_listen_port(&self) -> i32 {
|
|
return 8080;
|
|
}
|
|
|
|
}
|
|
|
|
impl UserApp {
|
|
|
|
pub fn new() -> Self {
|
|
let p = UserApp{
|
|
_self_wp: Default::default(),
|
|
};
|
|
return p;
|
|
}
|
|
|
|
}
|