diff --git a/f9/Cargo.toml b/f9/Cargo.toml index f38df25..02abcae 100644 --- a/f9/Cargo.toml +++ b/f9/Cargo.toml @@ -6,6 +6,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +serde = "*" +serde_derive = "*" +serde_json = "*" tokio = { version = "1", features = ["full"] } actix-web = "4" r9 = { path = "../r9" } diff --git a/f9/src/app.rs b/f9/src/app.rs index 7dd4799..7cffc8c 100644 --- a/f9/src/app.rs +++ b/f9/src/app.rs @@ -8,13 +8,15 @@ use actix_web::{ web, App as WebApp, web::Data, + web::Query, HttpRequest, HttpResponse, HttpServer, Responder}; use std::sync::{Arc, Mutex}; -//use std::collections::HashMap; +use std::collections::HashMap; use std::any::Any; +use serde_derive::Deserialize; use r9_macro::SharedFromSelf; use r9_macro_derive::SharedFromSelf; @@ -38,9 +40,16 @@ pub struct App { im_msgs: Rc::>>, im_work_msgs: Rc::>>, im_mutex: Mutex, + http_handlers: HashMap>>)>>, webapp_state: Arc::, } +#[derive(Deserialize)] +struct Ca { + c: String, + a: String +} + struct AppState { request: Arc>>>>, } @@ -58,6 +67,7 @@ struct HttpContext { query_str: String, add_tick: i64, handled: bool, + //not_found: bool, rsp: String } @@ -121,6 +131,7 @@ impl App { im_msgs: r9::ListHead::::new_head(), im_work_msgs: r9::ListHead::::new_head(), im_mutex: Mutex::new(1), + http_handlers: Default::default(), webapp_state: Arc::new( AppState{ request: Default::default() @@ -237,6 +248,9 @@ impl App { let c = v.pop(); match c { Some(v) => { + let query = web::Query::::from_query(&v.lock().unwrap().query_str).unwrap(); + + println!("c={}&a={}", query.c, query.a); v.lock().unwrap().rsp = "dsafsf".to_string(); v.lock().unwrap().handled = true; }