diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-08-28 16:40:24 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-08-28 16:40:24 -0400 |
commit | d149bf03647b09caa2af9e55a392251e4d619640 (patch) | |
tree | 6e2f3336d48205041fb515dbdd550a31c16dab22 | |
parent | 9908ae571c5b4086047443c8560cb65838b0caa2 (diff) | |
download | keysafe-d149bf03647b09caa2af9e55a392251e4d619640.tar.gz |
simplify http api, remove apiversion
Not needed since all routes are tagged with the api version.
-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!" |