feat(main): Support CONVERSE_BIND_HOST environment variable

This commit is contained in:
Vincent Ambo 2018-04-08 18:44:41 +02:00
parent a1a6b77fdf
commit 67a0642f8c

View file

@ -106,6 +106,8 @@ fn main() {
let db_addr = SyncArbiter::start(2, move || DbExecutor(pool.clone())); let db_addr = SyncArbiter::start(2, move || DbExecutor(pool.clone()));
info!("Initialising HTTP server ..."); info!("Initialising HTTP server ...");
let bind_host = env::var("CONVERSE_BIND_HOST").unwrap_or("127.0.0.1:4567".into());
server::new(move || { server::new(move || {
let template_path = concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*"); let template_path = concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*");
let tera = compile_templates!(template_path); let tera = compile_templates!(template_path);
@ -113,8 +115,9 @@ fn main() {
App::with_state(AppState { db: db_addr.clone(), tera }) App::with_state(AppState { db: db_addr.clone(), tera })
.middleware(middleware::Logger::default()) .middleware(middleware::Logger::default())
.resource("/", |r| r.method(Method::GET).with(forum_index)) .resource("/", |r| r.method(Method::GET).with(forum_index))
.resource("/thread/{id}", |r| r.method(Method::GET).with2(forum_thread)) .resource("/thread/{id}", |r| r.method(Method::GET).with2(forum_thread))})
}).bind("127.0.0.1:4567").unwrap().start(); .bind(&bind_host).expect(&format!("Could not bind on '{}'", bind_host))
.start();
let _ = sys.run(); let _ = sys.run();
} }