diff --git a/public/.well-known/matrix/client b/public/.well-known/matrix/client deleted file mode 100644 index 42afc11..0000000 --- a/public/.well-known/matrix/client +++ /dev/null @@ -1 +0,0 @@ -{ "m.homeserver": { "base_url": "https://matrix.envs.net" } } \ No newline at end of file diff --git a/public/.well-known/matrix/server b/public/.well-known/matrix/server deleted file mode 100644 index 6bfd601..0000000 --- a/public/.well-known/matrix/server +++ /dev/null @@ -1 +0,0 @@ -{ "m.server": "dendrite.neo.ixvd.net:443" } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index b8d4aaa..3db6a04 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,12 @@ use std::env; + use actix_files as fs; -use actix_web::{App, HttpServer, middleware, web}; +use actix_web::{App, HttpServer, middleware}; +use actix_web::web::Redirect; use env_logger; mod relay; +mod well_known; #[actix_web::main] async fn main() -> std::io::Result<()> { @@ -13,6 +16,7 @@ async fn main() -> std::io::Result<()> { App::new() .wrap(middleware::Logger::default()) .configure(relay::configure) + .configure(well_known::configure) .service( fs::Files::new("/", "./public/") .index_file("index.html") diff --git a/src/relay.rs b/src/relay.rs index a9f6c49..cf40221 100644 --- a/src/relay.rs +++ b/src/relay.rs @@ -1,4 +1,4 @@ -use actix_web::{HttpResponse, web, get}; +use actix_web::{get, HttpResponse, web}; use actix_web::http::StatusCode; #[get("/gatus")] diff --git a/src/well_known.rs b/src/well_known.rs new file mode 100644 index 0000000..b2c26f1 --- /dev/null +++ b/src/well_known.rs @@ -0,0 +1,24 @@ +use actix_web::{get, HttpResponse, web}; +use actix_web::http::StatusCode; + +#[get("/matrix/server")] +pub async fn get_matrix_server() -> HttpResponse { + HttpResponse::build(StatusCode::OK) + .content_type("application/json") + .body("{ \"m.server\": \"matrix.neo.ixvd.net:443\" }") +} + +#[get("/matrix/client")] +pub async fn get_matrix_client() -> HttpResponse { + HttpResponse::build(StatusCode::OK) + .content_type("application/json") + .body("{ \"m.homeserver\": { \"base_url\": \"https://matrix.neo.ixvd.net:443\" } }") +} + +pub fn configure(cfg: &mut web::ServiceConfig) { + cfg.service( + web::scope("/.well-known") + .service(get_matrix_server) + .service(get_matrix_client) + ); +} \ No newline at end of file