feat: Make the bind address configurable
This commit is contained in:
parent
2c27dc3bf6
commit
39adc3fb62
|
@ -1,2 +1,3 @@
|
||||||
[settings]
|
[settings]
|
||||||
base_directory = "/strg/drw"
|
base_directory = "/strg/drw"
|
||||||
|
bind_address = "127.0.0.1:3012"
|
||||||
|
|
|
@ -10,6 +10,7 @@ pub struct Config {
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
pub base_directory: String,
|
pub base_directory: String,
|
||||||
|
pub bind_address: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_config() -> Result<Config, Box<dyn std::error::Error>> {
|
pub fn read_config() -> Result<Config, Box<dyn std::error::Error>> {
|
||||||
|
|
|
@ -15,6 +15,7 @@ pub async fn list_files(
|
||||||
let template = ListTemplate {
|
let template = ListTemplate {
|
||||||
files: files.to_vec(),
|
files: files.to_vec(),
|
||||||
};
|
};
|
||||||
|
|
||||||
HtmlTemplate(template)
|
HtmlTemplate(template)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,9 @@ async fn main() {
|
||||||
)
|
)
|
||||||
.with_state(files);
|
.with_state(files);
|
||||||
|
|
||||||
let listener = TcpListener::bind("127.0.0.1:3004").await.unwrap();
|
let listener = TcpListener::bind(config.settings.bind_address)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
println!("Listening on {}", listener.local_addr().unwrap());
|
println!("Listening on {}", listener.local_addr().unwrap());
|
||||||
axum::serve(listener, app).await.unwrap();
|
axum::serve(listener, app).await.unwrap();
|
||||||
|
|
Loading…
Reference in New Issue