From f4a3240cc88ede6beb4565c00433aff656ff1ab9 Mon Sep 17 00:00:00 2001 From: Magnus Hallin Date: Sun, 18 Sep 2016 15:40:38 +0200 Subject: [PATCH] Read environment variable in example server --- examples/server.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/server.rs b/examples/server.rs index 53f1bc5c..43053c0b 100644 --- a/examples/server.rs +++ b/examples/server.rs @@ -4,6 +4,8 @@ extern crate logger; extern crate rustc_serialize; #[macro_use] extern crate juniper; +use std::env; + use mount::Mount; use logger::Logger; use iron::prelude::*; @@ -29,9 +31,9 @@ fn main() { chain.link_before(logger_before); chain.link_after(logger_after); - let host = "localhost:8080"; + let host = env::var("LISTEN").unwrap_or("0.0.0.0:8080".to_owned()); println!("GraphQL server started on {}", host); - Iron::new(chain).http(host).unwrap(); + Iron::new(chain).http(host.as_str()).unwrap(); } struct Query {}