summaryrefslogtreecommitdiff
path: root/src/server.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/server.rs')
-rw-r--r--src/server.rs24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/server.rs b/src/server.rs
index 9e63cb3..f34489f 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -5,7 +5,7 @@ use iron_sessionstorage::backends::SignedCookieBackend;
use iron::status;
use iron::modifiers::Header;
use iron::headers::ContentType;
-use iron::{Iron, Request, IronResult, Response, Chain, Listening};
+use iron::{Iron, IronError, Request, IronResult, Response, Chain, Listening};
use iron::error::{HttpResult};
use router::Router;
use systemd::unit;
@@ -33,12 +33,6 @@ impl iron_sessionstorage::Value for Login {
fn overview(r: &mut Request) -> IronResult<Response> {
let mut _value = try!(r.session().get::<Login>());
- let name = r.extensions
- .get::<Router>()
- .unwrap()
- .find("name")
- .unwrap_or("World").to_owned();
-
let units = unit::get_units("*").unwrap();
let sections = ["service", "timer", "socket", "target", "slice", "mount",
@@ -98,10 +92,26 @@ fn unit_status(r: &mut Request) -> IronResult<Response> {
render::unit_status(&unit, &log))))
}
+fn login(r: &mut Request) -> IronResult<Response> {
+ Ok(Response::with((status::Ok,
+ Header(ContentType::html()),
+ render::login_page())))
+}
+
+fn login_submit(r: &mut Request) -> IronResult<Response> {
+ Ok(Response::with((status::Ok,
+ Header(ContentType::plaintext()),
+ "login")))
+ // TODO: Need this to get params:
+ // https://github.com/iron/params
+}
+
pub fn serve(port: u16) -> HttpResult<Listening> {
let secret = b"secret2".to_vec();
let router = router!(
root: get "/" => overview,
+ login: get "/login" => login,
+ login_submit: post "/login" => login_submit,
details: get "/status/:unit" => unit_status,
journal: get "/journal/:unit" => journal,
css: get "/static/main.css" => Static::new(""),