api: stuff all the endpoints under /api/v1/

This commit is contained in:
Thomas R. Koll 2016-01-19 09:15:59 +01:00
parent 60de5a0df4
commit efd1d8cdcd

View File

@ -82,21 +82,25 @@ type HledgerApi =
:<|> "accounts" :> Get '[JSON] [Account]
:<|> "accounts" :> Capture "acct" AccountName :> Get '[JSON] AccountTransactionsReport
type CombinedServer =
"api" :>
"v1" :> HledgerApi
:<|> Raw
hledgerApiApp :: Journal -> Wai.Application
hledgerApiApp j = Servant.serve api server
hledgerApiApp j = Servant.serve api combinedServer
where
api :: Proxy HledgerApi
api :: Proxy CombinedServer
api = Proxy
server :: Server HledgerApi
server =
apiServer :: Server HledgerApi
apiServer =
accountnamesH
:<|> transactionsH
:<|> pricesH
:<|> commoditiesH
:<|> accountsH
:<|> accounttransactionsH
:<|> serveDirectory "static"
where
accountnamesH = return $ journalAccountNames j
transactionsH = return $ jtxns j
@ -114,6 +118,10 @@ hledgerApiApp j = Servant.serve api server
thisacctq = Acct $ accountNameToAccountRegex a -- includes subs
return $ accountTransactionsReport ropts j q thisacctq
combinedServer :: Server CombinedServer
combinedServer = apiServer
:<|> serveDirectory "static"
-- brief toJSON definitions included to avoid https://github.com/bos/aeson/issues/290
-- use toEncoding = genericToEncoding defaultOptions instead ?
instance ToJSON ClearedStatus where toJSON = genericToJSON defaultOptions