conduit/src/main.rs

93 lines
3.4 KiB
Rust
Raw Normal View History

2020-02-15 21:42:21 +00:00
#![feature(proc_macro_hygiene, decl_macro)]
#![warn(rust_2018_idioms)]
2020-04-11 07:30:11 +00:00
mod client_server;
mod database;
mod error;
2020-04-04 09:53:37 +00:00
mod pdu;
2020-02-15 21:42:21 +00:00
mod ruma_wrapper;
2020-04-19 12:14:47 +00:00
mod server_server;
2020-03-29 11:48:44 +00:00
mod utils;
2020-02-15 21:42:21 +00:00
#[cfg(test)]
mod test;
pub use database::Database;
pub use error::{Error, Result};
2020-04-04 09:53:37 +00:00
pub use pdu::PduEvent;
2020-04-11 07:30:11 +00:00
pub use ruma_wrapper::{MatrixResult, Ruma};
2020-04-29 06:48:56 +00:00
use rocket::{fairing::AdHoc, routes};
2020-04-29 06:48:56 +00:00
fn setup_rocket() -> rocket::Rocket {
2020-02-15 21:42:21 +00:00
rocket::ignite()
2020-02-18 21:07:57 +00:00
.mount(
"/",
routes![
2020-04-11 07:30:11 +00:00
client_server::get_supported_versions_route,
client_server::get_register_available_route,
2020-04-11 07:30:11 +00:00
client_server::register_route,
client_server::get_login_route,
client_server::login_route,
2020-04-19 12:14:47 +00:00
client_server::get_capabilities_route,
2020-04-11 07:30:11 +00:00
client_server::get_pushrules_all_route,
client_server::set_pushrule_route,
client_server::set_pushrule_enabled_route,
2020-04-11 07:30:11 +00:00
client_server::get_filter_route,
client_server::create_filter_route,
client_server::set_global_account_data_route,
client_server::get_global_account_data_route,
client_server::set_displayname_route,
client_server::get_displayname_route,
client_server::set_avatar_url_route,
client_server::get_avatar_url_route,
client_server::get_profile_route,
client_server::set_presence_route,
client_server::get_keys_route,
client_server::upload_keys_route,
client_server::set_read_marker_route,
2020-04-12 19:12:50 +00:00
client_server::create_typing_event_route,
2020-04-11 07:30:11 +00:00
client_server::create_room_route,
client_server::get_alias_route,
client_server::join_room_by_id_route,
client_server::join_room_by_id_or_alias_route,
2020-04-19 12:14:47 +00:00
client_server::leave_room_route,
2020-04-28 17:56:34 +00:00
client_server::forget_room_route,
client_server::invite_user_route,
2020-04-11 07:30:11 +00:00
client_server::get_public_rooms_filtered_route,
client_server::search_users_route,
2020-04-19 12:14:47 +00:00
client_server::get_member_events_route,
2020-04-11 07:30:11 +00:00
client_server::get_protocols_route,
client_server::create_message_event_route,
client_server::create_state_event_for_key_route,
client_server::create_state_event_for_empty_key_route,
client_server::sync_route,
2020-04-28 17:56:34 +00:00
client_server::get_message_events_route,
client_server::turn_server_route,
client_server::publicised_groups_route,
client_server::send_event_to_device_route,
client_server::get_media_config_route,
2020-04-11 07:30:11 +00:00
client_server::options_route,
2020-04-22 18:55:11 +00:00
server_server::well_known_server,
server_server::get_server_version,
server_server::get_server_keys,
server_server::get_server_keys_deprecated,
2020-02-18 21:07:57 +00:00
],
)
2020-04-29 06:48:56 +00:00
.attach(AdHoc::on_attach("Config", |rocket| {
let hostname = rocket.config().get_str("hostname").unwrap_or("localhost");
let data = Database::load_or_create(&hostname);
2020-04-29 06:48:56 +00:00
Ok(rocket.manage(data))
}))
}
fn main() {
// Log info by default
if let Err(_) = std::env::var("RUST_LOG") {
2020-04-19 12:14:47 +00:00
std::env::set_var("RUST_LOG", "warn");
}
2020-04-29 06:48:56 +00:00
setup_rocket().launch().unwrap();
2020-02-15 21:42:21 +00:00
}