Minor cleanup

This commit is contained in:
Antoine Gersant 2016-08-17 00:37:32 -07:00
parent 259699a3e8
commit 00b4d4cb77

View file

@ -1,13 +1,13 @@
use core::str::Utf8Error;
use std::path::PathBuf;
use std::ops::Deref;
use iron::prelude::*;
use iron::status;
use mount::Mount;
use url::percent_encoding::percent_decode;
use collection::browse as collection_browse;
use collection::flatten as collection_flatten;
use collection;
pub fn get_api_handler() -> Mount {
let mut mount = Mount::new();
@ -19,7 +19,7 @@ pub fn get_api_handler() -> Mount {
fn path_from_request(request: &Request) -> Result<PathBuf, Utf8Error> {
let path_string = request.url.path().join("/");
let decoded_path = percent_decode(path_string.as_bytes()).decode_utf8();
decoded_path.map(|s| PathBuf::from(s.into_owned()))
decoded_path.map(|s| PathBuf::from(s.deref()))
}
fn browse(request: &mut Request) -> IronResult<Response> {
@ -27,7 +27,7 @@ fn browse(request: &mut Request) -> IronResult<Response> {
if path.is_err() {
return Ok(Response::with((status::BadRequest)));
}
collection_browse(&path.unwrap());
collection::browse(&path.unwrap());
Ok(Response::with((status::Ok, "TODO browse data here")))
}
@ -36,6 +36,6 @@ fn flatten(request: &mut Request) -> IronResult<Response> {
if path.is_err() {
return Ok(Response::with((status::BadRequest)));
}
collection_flatten(&path.unwrap());
collection::flatten(&path.unwrap());
Ok(Response::with((status::Ok, "TODO Flatten data here")))
}