A peer-to-peer stack for code collaboration
Composable servant API definition
Thomas Scholtesfdc9e08d7edd
diff --git a/exe/Daemon.hs b/exe/Daemon.hsindex 4279149..fb81a19 100644--- a/exe/Daemon.hs+++ b/exe/Daemon.hs@@ -153,8 +153,7 @@ server :: Env -> Server DaemonApiserver env = hoistServer daemonApi nt daemonServerwheredaemonServer :: ServerT DaemonApi Daemon- daemonServer = (machineEndpoints :<|> newMachine) :<|> pure swagger- machineEndpoints id = query id :<|> send id+ daemonServer = newMachine :<|> query :<|> send :<|> pure swaggernt :: Daemon a -> Handler ant d = dodiff --git a/src/Radicle/Daemon/HttpApi.hs b/src/Radicle/Daemon/HttpApi.hsindex b5c1627..71368cf 100644--- a/src/Radicle/Daemon/HttpApi.hs+++ b/src/Radicle/Daemon/HttpApi.hs@@ -2,11 +2,18 @@module Radicle.Daemon.HttpApi( QueryRequest(..), QueryResponse(..)+ , machineQueryEndpoint+, SendRequest(..), SendResponse(..)+ , machineSendEndpoint+, NewResponse(..)+ , newMachineEndpoint+, DaemonApi, daemonApi+, swagger) where@@ -69,14 +76,26 @@ instance A.ToJSON NewResponse-- * APIs-type Query = "query" :> ReqBody '[JSON] QueryRequest :> Post '[JSON] QueryResponse-type Send = "send" :> ReqBody '[JSON] SendRequest :> Post '[JSON] SendResponse-type New = "new" :> Post '[JSON] NewResponse+type MachinesEndpoint t = "v0" :> "machines" :> t+type MachineEndpoint t = MachinesEndpoint (Capture "machineId" MachineId :> t)++type MachineQueryEndpoint = MachineEndpoint ("query" :> ReqBody '[JSON] QueryRequest :> Post '[JSON] QueryResponse)+machineQueryEndpoint :: Proxy MachineQueryEndpoint+machineQueryEndpoint = Proxy++type MachineSendEndpoint = MachineEndpoint ("send" :> ReqBody '[JSON] SendRequest :> Post '[JSON] SendResponse)+machineSendEndpoint :: Proxy MachineSendEndpoint+machineSendEndpoint = Proxy-type Machines = "machines" :> Capture "machineId" MachineId :> ( Query :<|> Send ) :<|> New-type Docs = "docs" :> Get '[JSON] Swagger+type NewMachineEndpoint = MachinesEndpoint ("new" :> Post '[JSON] NewResponse)+newMachineEndpoint :: Proxy NewMachineEndpoint+newMachineEndpoint = Proxy-type DaemonApi = "v0" :> ( Machines :<|> Docs )+type DaemonApi =+ NewMachineEndpoint+ :<|> MachineQueryEndpoint+ :<|> MachineSendEndpoint+ :<|> "v0" :> "docs" :> Get '[JSON] SwaggerdaemonApi :: Proxy DaemonApidaemonApi = Proxy