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