about summary refs log tree commit diff
path: root/Utilities/LibMatrix.HomeserverEmulator/Controllers/WellKnownController.cs
blob: 97e460d55e13b9ec396cda7dd5cefde70d37f7ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Text.Json.Nodes;
using LibMatrix.Services;
using Microsoft.AspNetCore.Mvc;

namespace LibMatrix.HomeserverEmulator.Controllers;

[ApiController]
[Route("/.well-known/matrix/")]
public class WellKnownController(ILogger<WellKnownController> logger) : ControllerBase {
    [HttpGet("client")]
    public JsonObject GetClientWellKnown() {
        var obj = new JsonObject() {
            ["m.homeserver"] = new JsonObject() {
                ["base_url"] = $"{Request.Scheme}://{Request.Host}"
            }
        };

        logger.LogInformation("Serving client well-known: {}", obj);

        return obj;
    }
    [HttpGet("server")]
    public JsonObject GetServerWellKnown() {
        var obj = new JsonObject() {
            ["m.server"] = $"{Request.Scheme}://{Request.Host}"
        };

        logger.LogInformation("Serving server well-known: {}", obj);

        return obj;
    }
}