Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Allow setting bind address #21

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::env;
use std::net::SocketAddr;

use crate::time::SystemTime;

Expand All @@ -14,6 +13,7 @@ mod token;
#[tokio::main]
async fn main() {
let use_print_sink = env::var("PRINT_SINK").is_ok();
let address = env::var("ADDRESS").unwrap_or(String::from("127.0.0.1:3000"));

let app = if use_print_sink {
router::router(SystemTime {}, sink::PrintSink {})
Expand All @@ -31,11 +31,10 @@ async fn main() {

// run our app with hyper
// `axum::Server` is a re-export of `hyper::Server`
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));

tracing::debug!("listening on {}", addr);
tracing::info!("listening on {}", address);

axum::Server::bind(&addr)
axum::Server::bind(&address.parse().unwrap())
.serve(app.into_make_service())
.await
.unwrap();
Expand Down