diff options
author | Till Hoeppner | 2014-11-30 17:51:24 +0100 |
---|---|---|
committer | Till Hoeppner | 2014-11-30 18:59:47 +0100 |
commit | 042f7414c229d1c7f66aef24faa92defb91a78cf (patch) | |
tree | 99ce32649aecb606d6a2d9d8a1d483567e83fc55 | |
parent | c19e787b018e4a95924972e5c7d63380abba4237 (diff) | |
download | sersve-042f7414c229d1c7f66aef24faa92defb91a78cf.tar.gz sersve-042f7414c229d1c7f66aef24faa92defb91a78cf.tar.xz sersve-042f7414c229d1c7f66aef24faa92defb91a78cf.zip |
Add minimal configuration
-rw-r--r-- | minimal.json | 6 | ||||
-rw-r--r-- | src/sersve.rs | 2 |
2 files changed, 8 insertions, 0 deletions
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": "<!DOCTYPE html><html><title>{{title}}</title><body><div id=\"container\"><h1>{{title}}</h1><table><thead><tr><th>Name</th><th>Size</th></tr></thead><tbody>{{#content}} <tr> <td> <a href=\"/{{url}}\">{{name}}</a> </td> <td> {{size}} </td> </tr> {{/content}} </tbody> </table> </div> </body></html>" +} 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.") |