Add the handler for converting temp list data to HTML

This commit is contained in:
Paul van Tilburg 2017-12-27 21:32:16 +01:00
parent b01d331742
commit 85e25a9b5c
1 changed files with 7 additions and 1 deletions

View File

@ -39,6 +39,12 @@ fn index(lists: State<ListStore>) -> Template {
Template::render("index", &context)
}
#[post("/lists", format = "application/json", data = "<tmp_list>")]
fn list_new(tmp_list: Json<List>) -> Option<String> {
let html = list::data_to_html(&tmp_list.data);
Some(html)
}
#[get("/lists/<list_id>", format = "text/html")]
fn list_show_html(list_id: String, lists: State<ListStore>) -> Option<String> {
let lists = lists.read().unwrap();
@ -66,7 +72,7 @@ fn rocket() -> Rocket {
let lists = list::List::load_all();
rocket::ignite()
.manage(RwLock::new(lists))
.mount("/", routes![index, list_show_html, list_show_json, list_update, static_files::all])
.mount("/", routes![index, list_new, list_show_html, list_show_json, list_update, static_files::all])
.attach(Template::fairing())
}