actually listen to the bind address

This commit is contained in:
Michael 2018-08-16 01:50:00 +00:00 committed by Michael Zhang
parent c5b6f4e993
commit 18a3e9e240
No known key found for this signature in database
GPG key ID: A1B65B603268116B

View file

@ -17,7 +17,9 @@ pub mod handler;
pub mod hook;
use std::collections::HashMap;
use std::net::SocketAddrV4;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::{mpsc, Mutex};
use std::thread;
use std::time::Duration;
@ -180,9 +182,8 @@ pub fn run(config: &Config) -> Result<(), Error> {
let v = config.root.clone();
thread::spawn(|| watch(v));
let addr = ([127, 0, 0, 1], 3000).into();
let server = Server::bind(&addr)
let addr: SocketAddrV4 = SocketAddrV4::from_str(config.bind.as_ref())?;
let server = Server::bind(&addr.into())
.serve(|| service_fn_ok(service_fn_wrapper))
.map_err(|e| eprintln!("server error: {}", e));
println!("Listening on {:?}", addr);