use rocket::{http::Status, serde::json::Json}; use super::{json_result::JsonResult, session::request}; // Instead of requesting pages and managing session & cookies manually, // create a wrapper that: // - Checks if the session cookie is valid // - If not, tries to login // - Makes the request // - Returns the html string, or an error #[get("/classroom/users/")] pub async fn get_users(full_name: String) -> (Status, Json>) { let html = request(format!("/main/admin/user_list.php?keyword={}&submit=&_qf__search_simple=", full_name)).await; match html { Ok(html) => { println!("{}", html); (Status::Ok, JsonResult::ok(())) } Err(reason) => { (Status::InternalServerError, JsonResult::err(reason)) } } }