diff options
-rw-r--r-- | HTTP.hs | 3 | ||||
-rw-r--r-- | HTTP/Client.hs | 10 | ||||
-rw-r--r-- | HTTP/Server.hs | 6 |
3 files changed, 6 insertions, 13 deletions
@@ -26,8 +26,7 @@ import qualified Raaz.Core.Encode as Raaz -- | Keysafe's http API type HttpAPI = - "keysafe" :> "apiversion" :> Get '[JSON] APIVersion - :<|> "keysafe" :> V1 :> "motd" :> Get '[JSON] Motd + "keysafe" :> V1 :> "motd" :> Get '[JSON] Motd :<|> "keysafe" :> V1 :> "objects" :> ObjectIdent :> POWParam :> Get '[JSON] (ProofOfWorkRequirement StorableObject) :<|> "keysafe" :> V1 :> "objects" :> ObjectIdent :> POWParam diff --git a/HTTP/Client.hs b/HTTP/Client.hs index 4a5106b..0a79ba0 100644 --- a/HTTP/Client.hs +++ b/HTTP/Client.hs @@ -13,13 +13,11 @@ import Servant.Client import Data.Proxy import Network.HTTP.Client (Manager) -apiVersion :: Manager -> BaseUrl -> ClientM APIVersion +httpAPI :: Proxy HttpAPI +httpAPI = Proxy + motd :: Manager -> BaseUrl -> ClientM Motd getObject :: StorableObjectIdent -> Maybe ProofOfWork -> Manager -> BaseUrl -> ClientM (ProofOfWorkRequirement StorableObject) putObject :: StorableObjectIdent -> Maybe ProofOfWork -> StorableObject -> Manager -> BaseUrl -> ClientM (ProofOfWorkRequirement StoreResult) countObjects :: Maybe ProofOfWork -> Manager -> BaseUrl -> ClientM (ProofOfWorkRequirement CountResult) -apiVersion - :<|> motd - :<|> getObject - :<|> putObject - :<|> countObjects = client (Proxy :: Proxy HttpAPI) +motd :<|> getObject :<|> putObject :<|> countObjects = client httpAPI diff --git a/HTTP/Server.hs b/HTTP/Server.hs index a26cd5e..7086167 100644 --- a/HTTP/Server.hs +++ b/HTTP/Server.hs @@ -44,15 +44,11 @@ userAPI :: Proxy HttpAPI userAPI = Proxy server :: ServerState -> Server HttpAPI -server st = apiVersion - :<|> motd +server st = motd :<|> getObject st :<|> putObject st :<|> countObjects st -apiVersion :: Handler APIVersion -apiVersion = return (APIVersion 1) - motd :: Handler Motd motd = return $ Motd "Hello World!" |