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    OwnedServerName,
9    api::{auth_scheme::NoAuthentication, request, response},
10    metadata,
11};
12
13metadata! {
14    method: GET,
15    rate_limited: false,
16    authentication: NoAuthentication,
17    path: "/.well-known/matrix/server",
18}
19
20/// Request type for the `discover_homeserver` endpoint.
21#[request]
22#[derive(Default)]
23pub struct Request {}
24
25/// Response type for the `discover_homeserver` endpoint.
26#[response]
27pub struct Response {
28    /// The server name to delegate server-server communications to, with optional port.
29    #[serde(rename = "m.server")]
30    pub server: OwnedServerName,
31}
32
33impl Request {
34    /// Creates an empty `Request`.
35    pub fn new() -> Self {
36        Self {}
37    }
38}
39
40impl Response {
41    /// Creates a new `Response` with the given homeserver.
42    pub fn new(server: OwnedServerName) -> Self {
43        Self { server }
44    }
45}