From 042f7414c229d1c7f66aef24faa92defb91a78cf Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Sun, 30 Nov 2014 17:51:24 +0100 Subject: Add minimal configuration --- minimal.json | 6 ++++++ src/sersve.rs | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 minimal.json diff --git a/minimal.json b/minimal.json new file mode 100644 index 0000000..f86b702 --- /dev/null +++ b/minimal.json @@ -0,0 +1,6 @@ +{ + "address": "0.0.0.0", + "port": 8080, + "root": "/home/till/", + "template": "{{title}}

{{title}}

{{#content}} {{/content}}
NameSize
{{name}} {{size}}
" +} diff --git a/src/sersve.rs b/src/sersve.rs index ebc4636..e7e39e2 100644 --- a/src/sersve.rs +++ b/src/sersve.rs @@ -217,6 +217,8 @@ fn main() { matches.opt_str("c").map(|conf_file| { let conf_file = File::open(&Path::new(conf_file)); conf_file.as_ref().map_err::<()>(|e| panic!("{}", e.desc)).unwrap(); + + // cannot if-let, because typesafe errors are helpful let json = match json::from_reader(&mut conf_file.ok().unwrap()) { Ok(Json::Object(o)) => o, _ => panic!("Invalid configuration file. Doesn't contain top-level object.") -- cgit v1.2.3