1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-12-26 09:04:39 +01:00

Add hostname to Rocket.toml config

This commit is contained in:
timokoesters 2020-04-29 08:48:56 +02:00
parent 23cb550d00
commit 1cdf30f38c
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
2 changed files with 11 additions and 8 deletions

View file

@ -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"

View file

@ -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();
}