ruma_federation_api/discovery/
discover_homeserver.rs

1//! `GET /.well-known/matrix/server` ([spec])
2//!
3//! Get discovery information about the domain.
4//!
5//! [spec]: https://spec.matrix.org/latest/server-server-api/#getwell-knownmatrixserver
6
7use ruma_common::{
8    api::{request, response, Metadata},
9    metadata, OwnedServerName,
10};
11
12const METADATA: Metadata = metadata! {
13    method: GET,
14    rate_limited: false,
15    authentication: None,
16    history: {
17        1.0 => "/.well-known/matrix/server",
18    }
19};
20
21/// Request type for the `discover_homeserver` endpoint.
22#[request]
23#[derive(Default)]
24pub struct Request {}
25
26/// Response type for the `discover_homeserver` endpoint.
27#[response]
28pub struct Response {
29    /// The server name to delegate server-server communications to, with optional port.
30    #[serde(rename = "m.server")]
31    pub server: OwnedServerName,
32}
33
34impl Request {
35    /// Creates an empty `Request`.
36    pub fn new() -> Self {
37        Self {}
38    }
39}
40
41impl Response {
42    /// Creates a new `Response` with the given homeserver.
43    pub fn new(server: OwnedServerName) -> Self {
44        Self { server }
45    }
46}