Skip to content

Commit 6a65225

Browse files
author
=
committed
add port argument
1 parent 3908ffc commit 6a65225

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ type Result<T = (), E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
44

55
#[tokio::main]
66
async fn main() -> Result {
7+
let port = std::env::args().skip(1).next().and_then(|s| {
8+
s.parse::<u16>().ok()
9+
}).unwrap_or(8080);
710
let app = Router::new()
811
.route("/delay/:secs", get(delay));
9-
let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await.unwrap();
12+
let listener = tokio::net::TcpListener::bind(("0.0.0.0", port)).await.unwrap();
1013
Ok(axum::serve(listener, app).await?)
1114
}
1215

0 commit comments

Comments
 (0)