From a0886694f73fc382d78da79ab8bfb27475757bab Mon Sep 17 00:00:00 2001 From: adambrangenberg Date: Wed, 24 Dec 2025 03:40:10 +0100 Subject: Implemented basic auth, refactor --- src/Endpoints/WellKnownEndpoint.hs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/Endpoints/WellKnownEndpoint.hs (limited to 'src/Endpoints/WellKnownEndpoint.hs') diff --git a/src/Endpoints/WellKnownEndpoint.hs b/src/Endpoints/WellKnownEndpoint.hs new file mode 100644 index 0000000..c63c5e5 --- /dev/null +++ b/src/Endpoints/WellKnownEndpoint.hs @@ -0,0 +1,37 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE TypeOperators #-} + +module Endpoints.WellKnownEndpoint (WellKnownAPI, wellKnownServer) where + +import Servant +import Data.Text (pack) + +import Model.WellKnown + +---------------------------------------------------------------------------------------------------- + +type WellKnownAPI = GetWellKnownClient :<|> GetWellKnownSupport + +wellKnownServer :: Server WellKnownAPI +wellKnownServer = handleWellKnownClientGet :<|> handleWellKnownSupportGet +--- GET /.well-known/matrix/client ----------------------------------------------------------------- + +type GetWellKnownClient = ".well-known" :> "matrix" :> "client" + :> Get '[JSON] WellKnownClientResponse + +handleWellKnownClientGet :: Handler WellKnownClientResponse +handleWellKnownClientGet = return $ WellKnownClientResponse + { homeserver = BaseUrlHolder (pack "http://localhost:8080") + , identity_server = BaseUrlHolder (pack "https://vector.im") + } + +--- GET /.well-known/matrix/support ---------------------------------------------------------------- +type GetWellKnownSupport = ".well-known" :> "matrix" :> "support" + :> Get '[JSON] WellKnownSupportResponse + +handleWellKnownSupportGet :: Handler WellKnownSupportResponse +handleWellKnownSupportGet = return $ WellKnownSupportResponse + { contacts = [Contact (pack "email") (pack "mxid") (pack "m.role.admin")] + , support_page = pack "http://localhost:8080/support.html" + } + -- cgit v1.2.3