diff options
author | Till Hoeppner | 2015-09-24 08:08:41 +0200 |
---|---|---|
committer | Till Hoeppner | 2015-09-24 08:08:41 +0200 |
commit | 9e961c2295f6c8010aeedf7e55f4049293207b7d (patch) | |
tree | cde83294fc8574f8321b7b4a71099030cf6d441d | |
parent | bcc686c84cbcae831aeacc3c9e17b8eaf495353a (diff) | |
download | sersve-9e961c2295f6c8010aeedf7e55f4049293207b7d.tar.gz sersve-9e961c2295f6c8010aeedf7e55f4049293207b7d.tar.xz sersve-9e961c2295f6c8010aeedf7e55f4049293207b7d.zip |
Fixed for updates
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | README.md | 24 | ||||
-rw-r--r-- | src/sersve.rs | 7 |
3 files changed, 20 insertions, 13 deletions
@@ -20,8 +20,10 @@ regex = "*" num_cpus = "*" serde = "*" serde_macros = "*" +serde_json = "*" lazy_static = "*" libc = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +env_logger = "*" @@ -18,18 +18,20 @@ target/release/sersve # target/sersve respectively ## Options ``` -Usage: target/release/sersve [options] -A minimal directory server, written in Rust with Iron. +A minimal static file server, written in Rust with Iron. +Usage: sersve [options] Options: - -c --config NAME set config file name - -a --address HOST the address to bind to - -p --port PORT the port to serve - -r --root ROOT the uppermost directory to serve - -f --filter REGEX a regular expression to filter the filenames - -s --size BYTES the maximum size of a file that will be served - -t --template TEMPLATE - a mustache template to use for rendering - -h --help print this help menu + -h, --help Show this message. + -v, --version Show the version of sersve (duh). + -c, --config FILE Provide a configuration file (JSON). + -a, --address HOST The address to bind to. + -p, --port PORT The port to serve. + -r, --root ROOT The uppermost directory to serve. + -f, --filter REGEX A regular expression to filter the filenames. + -s, --size BYTES The maximum size of a file that will be served. + -t, --template TEMPLATE A Mustache template to use for rendering. + --threads THREADS Amount of threads to use for serving. + --fork Fork sersve into a background process. ``` ## Configuration format diff --git a/src/sersve.rs b/src/sersve.rs index 1ed1129..e70e2bb 100644 --- a/src/sersve.rs +++ b/src/sersve.rs @@ -12,6 +12,8 @@ extern crate serde; extern crate lazy_static; extern crate docopt; extern crate rustc_serialize; +extern crate env_logger; +extern crate serde_json; use std::{ env, fs, process }; use std::path::{ Path, PathBuf }; @@ -25,7 +27,7 @@ use regex::Regex; use conduit_mime_types::Types; -use serde::json::{ self, Value }; +use serde_json::Value; use iron::prelude::*; use iron::status; @@ -101,7 +103,7 @@ lazy_static! { .unwrap(); // cannot if-let, because typesafe errors are helpful - let json = match json::from_str(&conf) { + let json = match serde_json::from_str(&conf) { Ok(Value::Object(o)) => o, _ => panic!("Invalid configuration file. Doesn't contain valid top-level object.") }; @@ -289,6 +291,7 @@ fn serve(req: &mut Request) -> IronResult<Response> { } fn main() { + env_logger::init().ok().expect("Unable to initialise env_logger."); let (host, port, threads) = { (ARGS.flag_address.clone().unwrap_or(HOST.into()), ARGS.flag_port.clone().unwrap_or(PORT), |