binding depends on compilation

This commit is contained in:
Mylloon 2024-11-26 13:23:16 +01:00
parent 50307d0c3e
commit 1bc845b398
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 14 additions and 1 deletions

View file

@ -4,6 +4,7 @@ use actix_web::{
web, App, HttpServer, web, App, HttpServer,
}; };
use std::io::Result; use std::io::Result;
use utils::misc::is_debug;
use crate::routes::{ use crate::routes::{
agreements, api_v1, blog, contact, contrib, cours, cv, gaming, index, memorial, not_found, agreements, api_v1, blog, contact, contrib, cours, cv, gaming, index, memorial, not_found,
@ -20,7 +21,10 @@ mod utils;
async fn main() -> Result<()> { async fn main() -> Result<()> {
let config = config::get_configuration("./config/config.toml"); let config = config::get_configuration("./config/config.toml");
let addr = ("0.0.0.0", config.fc.port.unwrap()); let addr = (
if is_debug() { "127.0.0.1" } else { "0.0.0.0" },
config.fc.port.unwrap(),
);
println!( println!(
"Listening to {}://{}:{}", "Listening to {}://{}:{}",

View file

@ -87,3 +87,12 @@ fn read_pdf(data: Vec<u8>) -> File {
), ),
} }
} }
#[cfg(debug_assertions)]
pub fn is_debug() -> bool {
true
}
#[cfg(not(debug_assertions))]
pub fn is_debug() -> bool {
false
}