mirror of
https://github.com/CCC-MF/bwhc-kafka-rest-proxy.git
synced 2025-07-02 08:22:54 +00:00
feat: add config option for listen address and port
This commit is contained in:
@ -27,4 +27,11 @@ pub struct Cli {
|
||||
help = "bcrypt hashed Security Token"
|
||||
)]
|
||||
pub token: String,
|
||||
#[arg(
|
||||
long,
|
||||
env = "APP_LISTEN",
|
||||
default_value = "0.0.0.0:3000",
|
||||
help = "Address and port for HTTP requests"
|
||||
)]
|
||||
pub listen: String,
|
||||
}
|
||||
|
11
src/main.rs
11
src/main.rs
@ -58,8 +58,15 @@ async fn main() {
|
||||
#[cfg(debug_assertions)]
|
||||
let app = app.layer(TraceLayer::new_for_http());
|
||||
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
match tokio::net::TcpListener::bind(&CONFIG.listen).await {
|
||||
Ok(listener) => {
|
||||
log::info!("Starting application listening on '{}'", CONFIG.listen);
|
||||
if let Err(err) = axum::serve(listener, app).await {
|
||||
log::error!("Error starting application: {}", err)
|
||||
}
|
||||
}
|
||||
Err(err) => log::error!("Error listening on '{}': {}", CONFIG.listen, err),
|
||||
};
|
||||
}
|
||||
|
||||
async fn check_basic_auth(request: Request<Body>, next: Next) -> Response {
|
||||
|
Reference in New Issue
Block a user