about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2018-04-08T16·44+0200
committerVincent Ambo <tazjin@gmail.com>2018-04-08T16·44+0200
commit67a0642f8c9b9f90c71ab8ca64be8e6ae15ff830 (patch)
tree83b4a46960088f1f733daf95535a7780d9f7abf8 /src
parenta1a6b77fdfee7fc8b3b9a8692cc4b6e3ec74247d (diff)
feat(main): Support CONVERSE_BIND_HOST environment variable
Diffstat (limited to 'src')
-rw-r--r--src/main.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 4d3d81c81356..3590975c8e9f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -106,6 +106,8 @@ fn main() {
     let db_addr = SyncArbiter::start(2, move || DbExecutor(pool.clone()));
 
     info!("Initialising HTTP server ...");
+    let bind_host = env::var("CONVERSE_BIND_HOST").unwrap_or("127.0.0.1:4567".into());
+
     server::new(move || {
         let template_path = concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*");
         let tera = compile_templates!(template_path);
@@ -113,8 +115,9 @@ fn main() {
         App::with_state(AppState { db: db_addr.clone(), tera })
             .middleware(middleware::Logger::default())
             .resource("/", |r| r.method(Method::GET).with(forum_index))
-            .resource("/thread/{id}", |r| r.method(Method::GET).with2(forum_thread))
-    }).bind("127.0.0.1:4567").unwrap().start();
+            .resource("/thread/{id}", |r| r.method(Method::GET).with2(forum_thread))})
+        .bind(&bind_host).expect(&format!("Could not bind on '{}'", bind_host))
+        .start();
 
     let _ = sys.run();
 }