web/
web.rs

1use std::path::PathBuf;
2use json::{JsonValue, object};
3use df_helper::files::file;
4use df_helper::http::web::{Web};
5
6fn main() {
7    let root_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
8    let root_path = root_path.to_str().unwrap();
9    let conf = file::file_content_get_json(format!("{}/tests/config/web.json", root_path.clone()).as_str());
10
11    Web::bind(conf["url"].as_str().unwrap(),
12              format!("{}/tests/public", root_path.clone()).as_str(),
13    ).run(conf["cors"].clone(), handle);
14
15    fn handle(response: JsonValue) -> (JsonValue, i32, String) {
16        println!("{:#}", response);
17        let text = object! {"name":"2313",response:response};
18        return (text, 200, "json".to_string());
19    }
20}