add support for serving client+server well-known and /client/server.json
endpoints from conduwuit
the last endpoint is a non-standard health check endpoint used by at least Element Web as a weird way to determine if syncv3 is available there can also be some valid use-cases for serving well-knowns from the application itself Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
bb2f213ac3
commit
8586b15e1a
5 changed files with 49 additions and 17 deletions
26
src/main.rs
26
src/main.rs
|
@ -514,7 +514,18 @@ fn routes() -> Router {
|
|||
"/_matrix/client/v3/rooms/:room_id/initialSync",
|
||||
get(initial_sync),
|
||||
)
|
||||
//.route("/client/server.json", get(syncv3_client_server_json))
|
||||
.route(
|
||||
"/client/server.json",
|
||||
get(client_server::syncv3_client_server_json),
|
||||
)
|
||||
.route(
|
||||
"/.well-known/matrix/client",
|
||||
get(client_server::well_known_client_route),
|
||||
)
|
||||
.route(
|
||||
"/.well-known/matrix/server",
|
||||
get(server_server::well_known_server_route),
|
||||
)
|
||||
.route("/", get(it_works))
|
||||
.fallback(not_found)
|
||||
}
|
||||
|
@ -572,19 +583,6 @@ async fn it_works() -> &'static str {
|
|||
"hewwo from conduwuit woof!"
|
||||
}
|
||||
|
||||
/*
|
||||
// TODO: add /client/server.json support by querying our client well-known for the true matrix homeserver URL
|
||||
async fn syncv3_client_server_json(uri: Uri) -> impl IntoResponse {
|
||||
let server_name = services().globals.server_name().to_string();
|
||||
let response = services().globals.default_client().get(&format!("https://{server_name"))
|
||||
let server = uri.scheme_str().unwrap_or("https").to_owned() + "://" + uri.host().unwrap();
|
||||
let version = format!("cowonduit {}", env!("CARGO_PKG_VERSION").to_owned());
|
||||
let body = format!("{{\"server\":\"{server}\",\"version\":\"{version}\"}}");
|
||||
|
||||
Json(body)
|
||||
}
|
||||
*/
|
||||
|
||||
trait RouterExt {
|
||||
fn ruma_route<H, T>(self, handler: H) -> Self
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue