use axum::extract::State; use conduwuit::{Err, Result}; use ruma::api::federation::discovery::discover_homeserver; use crate::Ruma; /// # `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, _body: Ruma, ) -> Result { 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."))), }, )) }