Commit 996ee1b0 authored by Robert Czechowski's avatar Robert Czechowski

Split up debug page into debug and db status page

parent 18c12db1
......@@ -90,6 +90,8 @@ pub fn index<T: MedalConnection>(conn: &T, session_token: Option<String>,
("index".to_owned(), data)
}
pub fn status<T: MedalConnection>(conn: &T) -> String { conn.get_debug_information() }
pub fn debug<T: MedalConnection>(conn: &T, session_token: Option<String>)
-> (String, json_val::Map<String, json_val::Value>) {
let mut data = json_val::Map::new();
......@@ -110,6 +112,10 @@ pub fn debug<T: MedalConnection>(conn: &T, session_token: Option<String>)
data.insert("firstname".to_string(), to_json(&session.firstname));
data.insert("lastname".to_string(), to_json(&session.lastname));
data.insert("teacher".to_string(), to_json(&session.is_teacher));
data.insert("oauth_provider".to_string(), to_json(&session.oauth_provider));
data.insert("oauth_id".to_string(), to_json(&session.oauth_foreign_id));
data.insert("lastname".to_string(), to_json(&session.lastname));
data.insert("teacher".to_string(), to_json(&session.is_teacher));
}
}
}
......@@ -118,8 +124,6 @@ pub fn debug<T: MedalConnection>(conn: &T, session_token: Option<String>)
data.insert("session".to_string(), to_json(&"No session token given"));
}
data.insert("dbinfo".to_string(), to_json(&conn.get_debug_information()));
("debug".to_owned(), data)
}
......
......@@ -303,6 +303,20 @@ fn greet_personal<C>(req: &mut Request) -> IronResult<Response>
Ok(resp)
}
fn dbstatus<C>(req: &mut Request) -> IronResult<Response>
where C: MedalConnection + std::marker::Send + 'static {
let status = {
let mutex = req.get::<Write<SharedDatabaseConnection<C>>>().unwrap();
let conn = mutex.lock().unwrap_or_else(|e| e.into_inner());
core::status(&*conn)
};
let mut resp = Response::new();
resp.set_mut(status).set_mut(status::Ok);
Ok(resp)
}
fn debug<C>(req: &mut Request) -> IronResult<Response>
where C: MedalConnection + std::marker::Send + 'static {
let session_token = req.get_session_token();
......@@ -1035,6 +1049,7 @@ pub fn start_server<C>(conn: C, config: Config) -> iron::error::HttpResult<iron:
task: get "/task/:taskid" => task::<C>,
oauth: get "/oauth/:oauthid" => oauth::<C>,
check_cookie: get "/cookie" => cookie_warning,
dbstatus: get "/dbstatus" => dbstatus::<C>,
debug: get "/debug" => debug::<C>,
debug_reset: get "/debug/reset" => debug_new_token::<C>,
debug_logout: get "/debug/logout" => debug_logout::<C>,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment