Skip to content

Commit

Permalink
Bugfix: Specify localhost listen endpoint will cause a panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
keuin committed Mar 28, 2022
1 parent 3c8531e commit 46b8386
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kimikuri_rs"
version = "0.5.0"
version = "0.5.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down Expand Up @@ -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));

Expand Down

0 comments on commit 46b8386

Please sign in to comment.