mirror of
https://github.com/SinTan1729/chhoto-url
synced 2025-02-05 13:52:33 -06:00
fix: Disregard empty Site URL
This commit is contained in:
parent
5183279cab
commit
eb4f05a87b
2 changed files with 8 additions and 6 deletions
|
@ -47,11 +47,10 @@ async fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell the user that the server has started, and where it is listening to, rather than simply outputting nothing
|
// Tell the user that the server has started, and where it is listening to, rather than simply outputting nothing
|
||||||
eprintln!(
|
eprintln!("Server has started at 0.0.0.0 on port {port}.");
|
||||||
"Server has started at 0.0.0.0 on port {}. Configured Site URL is: {}",
|
if let Some(site_url) = env::var("site_url").ok().filter(|s| !s.trim().is_empty()) {
|
||||||
port,
|
eprintln!("Configured Site URL is: {site_url}.");
|
||||||
env::var("site_url").unwrap_or(String::from("http://localhost"))
|
}
|
||||||
);
|
|
||||||
|
|
||||||
// Actually start the server
|
// Actually start the server
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
|
|
|
@ -61,7 +61,10 @@ pub async fn add_link(
|
||||||
.expect("Supplied port is not an integer");
|
.expect("Supplied port is not an integer");
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"{}:{}",
|
"{}:{}",
|
||||||
env::var("site_url").unwrap_or(String::from("http://localhost")),
|
env::var("site_url")
|
||||||
|
.ok()
|
||||||
|
.filter(|s| !s.trim().is_empty())
|
||||||
|
.unwrap_or(String::from("http://localhost")),
|
||||||
port
|
port
|
||||||
);
|
);
|
||||||
let response = CreatedURL {
|
let response = CreatedURL {
|
||||||
|
|
Loading…
Reference in a new issue