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.

19 lines
674 B
Rust
Raw Normal View History

2024-07-16 08:05:25 +00:00
use axum::extract::State;
2024-06-05 04:32:58 +00:00
use ruma::api::{client::error::ErrorKind, federation::discovery::discover_homeserver};
2024-07-16 08:05:25 +00:00
use crate::{Error, Result, 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(
2024-07-16 08:05:25 +00:00
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 {
2024-11-24 00:19:55 +00:00
server: match services.server.config.well_known.server.as_ref() {
2024-06-05 04:32:58 +00:00
Some(server_name) => server_name.to_owned(),
None => return Err(Error::BadRequest(ErrorKind::NotFound, "Not found.")),
},
})
}