Read environment variable in example server

This commit is contained in:
Magnus Hallin 2016-09-18 15:40:38 +02:00
parent 2c8fbee4c9
commit f4a3240cc8

View file

@ -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 {}