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
|
||||
eprintln!(
|
||||
"Server has started at 0.0.0.0 on port {}. Configured Site URL is: {}",
|
||||
port,
|
||||
env::var("site_url").unwrap_or(String::from("http://localhost"))
|
||||
);
|
||||
eprintln!("Server has started at 0.0.0.0 on port {port}.");
|
||||
if let Some(site_url) = env::var("site_url").ok().filter(|s| !s.trim().is_empty()) {
|
||||
eprintln!("Configured Site URL is: {site_url}.");
|
||||
}
|
||||
|
||||
// Actually start the server
|
||||
HttpServer::new(move || {
|
||||
|
|
|
@ -61,7 +61,10 @@ pub async fn add_link(
|
|||
.expect("Supplied port is not an integer");
|
||||
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
|
||||
);
|
||||
let response = CreatedURL {
|
||||
|
|
Loading…
Reference in a new issue