Files
continuwuity/src/api/server/well_known.rs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
669 B
Rust
Raw Normal View History

2024-07-16 08:05:25 +00:00
use axum::extract::State;
use conduwuit::{Err, Result};
use ruma::api::federation::discovery::discover_homeserver;
2024-06-05 04:32:58 +00:00
use crate::Ruma;
2024-06-05 04:32:58 +00:00
/// # `GET /.well-known/matrix/server`
///
/// Returns the .well-known URL if it is configured, otherwise returns 404.
pub(crate) async fn well_known_server(
State(services): State<crate::State>,
_body: Ruma<discover_homeserver::Request>,
2024-06-05 04:32:58 +00:00
) -> Result<discover_homeserver::Response> {
Ok(discover_homeserver::Response::new(
match services.server.config.well_known.server.as_ref() {
| Some(server_name) => server_name.to_owned(),
| None => return Err!(Request(NotFound("No well-known server URL is configured."))),
2024-06-05 04:32:58 +00:00
},
))
2024-06-05 04:32:58 +00:00
}