summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index e85b74e..d54a97c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,7 @@
use std::{io, path};
use std::collections::HashMap;
use std::convert::Infallible;
-use std::net::SocketAddr;
+use std::net::{SocketAddr, ToSocketAddrs};
use std::str::FromStr;
use teloxide::prelude2::*;
@@ -104,7 +104,11 @@ async fn main() {
info!("Starting HTTP server...");
let endpoint: SocketAddr = config.listen.parse()
- .expect("Cannot parse `listen` as endpoint.");
+ .unwrap_or_else(|_| config.listen
+ .to_socket_addrs()
+ .expect("Cannot resolve endpoint.")
+ .next()
+ .expect("Cannot resolve endpoint."));
info!("Start listening on {}", endpoint);
tokio::spawn(warp::serve(routes).run(endpoint));