aboutsummaryrefslogtreecommitdiff
path: root/src/Endpoints
diff options
context:
space:
mode:
authoradambrangenberg <adabran06@gmail.com>2025-12-07 06:36:43 +0100
committeradambrangenberg <adabran06@gmail.com>2025-12-07 06:36:43 +0100
commit2b48a574e8b9fed03a5c1969af4bb1e338f1be26 (patch)
treef31c92f7788969b034838b8ec0ea7e187a746fc2 /src/Endpoints
parentfb14daae9d3bc05a0d18f58875ef54e328081f19 (diff)
implemented section 1-3
Diffstat (limited to 'src/Endpoints')
-rw-r--r--src/Endpoints/APILib.hs11
-rw-r--r--src/Endpoints/ServerLib.hs12
-rw-r--r--src/Endpoints/VersionsEndpoint.hs12
-rw-r--r--src/Endpoints/WellKnownClientEndpoint.hs12
-rw-r--r--src/Endpoints/WellKnownSupportEndpoint.hs18
5 files changed, 65 insertions, 0 deletions
diff --git a/src/Endpoints/APILib.hs b/src/Endpoints/APILib.hs
new file mode 100644
index 0000000..9c89492
--- /dev/null
+++ b/src/Endpoints/APILib.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE DataKinds #-}
+
+module Endpoints.APILib (API) where
+
+import Servant
+import Endpoints.WellKnownClientEndpoint
+import Endpoints.WellKnownSupportEndpoint
+import Endpoints.VersionsEndpoint
+
+type API = WellKnownClientAPI :<|> WellKnownSupportAPI :<|> VersionsAPI
diff --git a/src/Endpoints/ServerLib.hs b/src/Endpoints/ServerLib.hs
new file mode 100644
index 0000000..cae6928
--- /dev/null
+++ b/src/Endpoints/ServerLib.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE TypeOperators #-}
+
+module Endpoints.ServerLib (server) where
+
+import Endpoints.WellKnownClientEndpoint
+import Endpoints.WellKnownSupportEndpoint
+import Endpoints.APILib
+import Endpoints.VersionsEndpoint
+import Servant
+
+server :: Server API
+server = handleWellKnownClient :<|> handleWellKnownSupport :<|> handleVersions
diff --git a/src/Endpoints/VersionsEndpoint.hs b/src/Endpoints/VersionsEndpoint.hs
new file mode 100644
index 0000000..79fd3ea
--- /dev/null
+++ b/src/Endpoints/VersionsEndpoint.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE TypeOperators #-}
+
+module Endpoints.VersionsEndpoint (VersionsAPI, handleVersions) where
+
+import Servant
+import Data.VersionsData
+
+type VersionsAPI = "_matrix" :> "client" :> "versions" :> Get '[JSON] Versions
+
+handleVersions :: Handler Versions
+handleVersions = return (makeVersions ["1.12"])
diff --git a/src/Endpoints/WellKnownClientEndpoint.hs b/src/Endpoints/WellKnownClientEndpoint.hs
new file mode 100644
index 0000000..d091b1d
--- /dev/null
+++ b/src/Endpoints/WellKnownClientEndpoint.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE TypeOperators #-}
+
+module Endpoints.WellKnownClientEndpoint (WellKnownClientAPI, handleWellKnownClient) where
+
+import Servant
+import Data.WellKnownClientData
+
+type WellKnownClientAPI = ".well-known" :> "matrix" :> "client" :> Get '[JSON] WellKnownClient
+
+handleWellKnownClient :: Handler WellKnownClient
+handleWellKnownClient = return (makeWellKnownClient "http://localhost:8080" "http://localhost:8080")
diff --git a/src/Endpoints/WellKnownSupportEndpoint.hs b/src/Endpoints/WellKnownSupportEndpoint.hs
new file mode 100644
index 0000000..b6104ae
--- /dev/null
+++ b/src/Endpoints/WellKnownSupportEndpoint.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE TypeOperators #-}
+
+module Endpoints.WellKnownSupportEndpoint (WellKnownSupportAPI, handleWellKnownSupport) where
+
+import Servant
+import Data.WellKnownSupportData
+import Data.ContactData
+
+type WellKnownSupportAPI = ".well-known" :> "matrix" :> "support" :> Get '[JSON] WellKnownSupport
+
+handleWellKnownSupport :: Handler WellKnownSupport
+handleWellKnownSupport =
+ return (
+ makeWellKnownSupport
+ [makeContact "email" "mxid" "m.role.admin"]
+ "http://localhost:8080/support.html"
+ )