diff options
Diffstat (limited to 'src/Endpoints')
| -rw-r--r-- | src/Endpoints/APILib.hs | 11 | ||||
| -rw-r--r-- | src/Endpoints/ServerLib.hs | 12 | ||||
| -rw-r--r-- | src/Endpoints/VersionsEndpoint.hs | 12 | ||||
| -rw-r--r-- | src/Endpoints/WellKnownClientEndpoint.hs | 12 | ||||
| -rw-r--r-- | src/Endpoints/WellKnownSupportEndpoint.hs | 18 |
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" + ) |