Don't attach Iron logger middleware on Windows

Fixes #15.
This commit is contained in:
Magnus Hallin 2017-02-04 10:30:46 +01:00
parent c1d8e6c19b
commit d87c6e4fa4

View file

@ -30,13 +30,18 @@ fn main() {
mount.mount("/", graphiql_endpoint); mount.mount("/", graphiql_endpoint);
mount.mount("/graphql", graphql_endpoint); mount.mount("/graphql", graphql_endpoint);
let (logger_before, logger_after) = Logger::new(None);
let mut chain = Chain::new(mount); let mut chain = Chain::new(mount);
chain.link_before(logger_before);
chain.link_after(logger_after); // Temporary fix - Iron's logger middleware does not work on Windows
#[cfg(not(windows))] setup_logger(&mut chain);
let host = env::var("LISTEN").unwrap_or("0.0.0.0:8080".to_owned()); let host = env::var("LISTEN").unwrap_or("0.0.0.0:8080".to_owned());
println!("GraphQL server started on {}", host); println!("GraphQL server started on {}", host);
Iron::new(chain).http(host.as_str()).unwrap(); Iron::new(chain).http(host.as_str()).unwrap();
} }
fn setup_logger(chain: &mut Chain) {
let (logger_before, logger_after) = Logger::new(None);
chain.link_before(logger_before);
chain.link_after(logger_after);
}