Add hostname to Rocket.toml config
This commit is contained in:
parent
23cb550d00
commit
1cdf30f38c
2 changed files with 11 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
|||
[global]
|
||||
address = "0.0.0.0"
|
||||
hostname = "conduit.rs"
|
||||
port = 14004
|
||||
address = "0.0.0.0"
|
||||
|
||||
[global.tls]
|
||||
certs = "/etc/letsencrypt/live/matrixtesting.koesters.xyz/fullchain.pem"
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -16,9 +16,9 @@ pub use database::Database;
|
|||
pub use pdu::PduEvent;
|
||||
pub use ruma_wrapper::{MatrixResult, Ruma};
|
||||
|
||||
use rocket::routes;
|
||||
use rocket::{fairing::AdHoc, routes};
|
||||
|
||||
fn setup_rocket(data: Data) -> rocket::Rocket {
|
||||
fn setup_rocket() -> rocket::Rocket {
|
||||
rocket::ignite()
|
||||
.mount(
|
||||
"/",
|
||||
|
@ -68,7 +68,12 @@ fn setup_rocket(data: Data) -> rocket::Rocket {
|
|||
server_server::get_server_keys_deprecated,
|
||||
],
|
||||
)
|
||||
.manage(data)
|
||||
.attach(AdHoc::on_attach("Config", |rocket| {
|
||||
let hostname = rocket.config().get_str("hostname").unwrap_or("localhost");
|
||||
let data = Data::load_or_create(&hostname);
|
||||
|
||||
Ok(rocket.manage(data))
|
||||
}))
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -78,8 +83,5 @@ fn main() {
|
|||
}
|
||||
pretty_env_logger::init();
|
||||
|
||||
let data = Data::load_or_create("conduit.rs");
|
||||
//data.debug();
|
||||
|
||||
setup_rocket(data).launch().unwrap();
|
||||
setup_rocket().launch().unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue