fix: .well-known

This commit is contained in:
Strix 2023-10-16 01:36:01 +02:00
parent 9ef5feafc7
commit d1d148456d
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774
5 changed files with 30 additions and 4 deletions

View file

@ -1 +0,0 @@
{ "m.homeserver": { "base_url": "https://matrix.envs.net" } }

View file

@ -1 +0,0 @@
{ "m.server": "dendrite.neo.ixvd.net:443" }

View file

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

View file

@ -1,4 +1,4 @@
use actix_web::{HttpResponse, web, get};
use actix_web::{get, HttpResponse, web};
use actix_web::http::StatusCode;
#[get("/gatus")]

24
src/well_known.rs Normal file
View file

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