Add hostname to Rocket.toml config
parent
23cb550d00
commit
1cdf30f38c
|
@ -1,6 +1,7 @@
|
||||||
[global]
|
[global]
|
||||||
address = "0.0.0.0"
|
hostname = "conduit.rs"
|
||||||
port = 14004
|
port = 14004
|
||||||
|
address = "0.0.0.0"
|
||||||
|
|
||||||
[global.tls]
|
[global.tls]
|
||||||
certs = "/etc/letsencrypt/live/matrixtesting.koesters.xyz/fullchain.pem"
|
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 pdu::PduEvent;
|
||||||
pub use ruma_wrapper::{MatrixResult, Ruma};
|
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()
|
rocket::ignite()
|
||||||
.mount(
|
.mount(
|
||||||
"/",
|
"/",
|
||||||
|
@ -68,7 +68,12 @@ fn setup_rocket(data: Data) -> rocket::Rocket {
|
||||||
server_server::get_server_keys_deprecated,
|
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() {
|
fn main() {
|
||||||
|
@ -78,8 +83,5 @@ fn main() {
|
||||||
}
|
}
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
let data = Data::load_or_create("conduit.rs");
|
setup_rocket().launch().unwrap();
|
||||||
//data.debug();
|
|
||||||
|
|
||||||
setup_rocket(data).launch().unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue