media-collection-crud/src/handlers.rs

33 lines
808 B
Rust

use handlebars_iron as hbi;
use iron::prelude::{Request, Response};
use iron::{IronResult, Set, status};
use mount::Mount;
use serde::ser::Serialize as ToJson;
use staticfile::Static;
use std::path::Path;
pub struct AssetsHandler;
impl AssetsHandler {
pub fn new(prefix: &str, mount_path: &str) -> Mount {
let mut assets_mount = Mount::new();
assets_mount.mount(prefix, Static::new(Path::new(mount_path)));
assets_mount
}
}
fn render_page<T: ToJson>(name: &str, value: T) -> hbi::Template {
unimplemented!();
}
pub fn hello_world (_request: &mut Request) -> IronResult<Response> {
use handlebars_iron::Template;
let mut response = Response::new();
response.set_mut(Template::new("index","".to_string()))
.set_mut(status::Ok);
Ok(response)
}