diff --git a/src/get.rs b/src/get.rs
index 9507125..eb2eb05 100644
--- a/src/get.rs
+++ b/src/get.rs
@@ -36,7 +36,7 @@ pub async fn get_id(
if url::Url::parse(&it.url).is_ok() {
if show_request {
return Html(format!(
- "
{}/{} -> {}
",
+ "http://{}/{} -> {}
",
state.host, it.id, it.url, it.url
))
.into_response();
diff --git a/src/main.rs b/src/main.rs
index 51dd969..57c6430 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,8 +11,6 @@ use info_utils::prelude::*;
pub mod get;
pub mod post;
-const LISTEN_ADDRESS: &'static str = "0.0.0.0:3000";
-
#[derive(Clone)]
pub struct ServerState {
pub db_pool: Pool,
@@ -32,14 +30,15 @@ async fn main() -> eyre::Result<()> {
let db_pool = init_db().await?;
- let server_state = ServerState {
- db_pool,
- host: "trkt.in".to_string(),
- };
+ let host = std::env::var("CHELA_HOST").unwrap_or("localhost".to_string());
+ let server_state = ServerState { db_pool, host };
+
+ let address = std::env::var("LISTEN_ADDRESS").unwrap_or("0.0.0.0".to_string());
+ let port = std::env::var("LISTEN_PORT").unwrap_or("3000".to_string());
let router = init_routes(server_state)?;
- let listener = tokio::net::TcpListener::bind(LISTEN_ADDRESS).await?;
- log!("Listening at {}", LISTEN_ADDRESS);
+ let listener = tokio::net::TcpListener::bind(format!("{}:{}", address, port)).await?;
+ log!("Listening at {}:{}", address, port);
axum::serve(
listener,
router.into_make_service_with_connect_info::(),