aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--minimal.json6
-rw-r--r--src/sersve.rs2
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.")