api: stuff all the endpoints under /api/v1/
This commit is contained in:
parent
60de5a0df4
commit
efd1d8cdcd
@ -82,21 +82,25 @@ type HledgerApi =
|
|||||||
:<|> "accounts" :> Get '[JSON] [Account]
|
:<|> "accounts" :> Get '[JSON] [Account]
|
||||||
:<|> "accounts" :> Capture "acct" AccountName :> Get '[JSON] AccountTransactionsReport
|
:<|> "accounts" :> Capture "acct" AccountName :> Get '[JSON] AccountTransactionsReport
|
||||||
|
|
||||||
|
type CombinedServer =
|
||||||
|
"api" :>
|
||||||
|
"v1" :> HledgerApi
|
||||||
|
:<|> Raw
|
||||||
|
|
||||||
hledgerApiApp :: Journal -> Wai.Application
|
hledgerApiApp :: Journal -> Wai.Application
|
||||||
hledgerApiApp j = Servant.serve api server
|
hledgerApiApp j = Servant.serve api combinedServer
|
||||||
where
|
where
|
||||||
api :: Proxy HledgerApi
|
api :: Proxy CombinedServer
|
||||||
api = Proxy
|
api = Proxy
|
||||||
|
|
||||||
server :: Server HledgerApi
|
apiServer :: Server HledgerApi
|
||||||
server =
|
apiServer =
|
||||||
accountnamesH
|
accountnamesH
|
||||||
:<|> transactionsH
|
:<|> transactionsH
|
||||||
:<|> pricesH
|
:<|> pricesH
|
||||||
:<|> commoditiesH
|
:<|> commoditiesH
|
||||||
:<|> accountsH
|
:<|> accountsH
|
||||||
:<|> accounttransactionsH
|
:<|> accounttransactionsH
|
||||||
:<|> serveDirectory "static"
|
|
||||||
where
|
where
|
||||||
accountnamesH = return $ journalAccountNames j
|
accountnamesH = return $ journalAccountNames j
|
||||||
transactionsH = return $ jtxns j
|
transactionsH = return $ jtxns j
|
||||||
@ -114,6 +118,10 @@ hledgerApiApp j = Servant.serve api server
|
|||||||
thisacctq = Acct $ accountNameToAccountRegex a -- includes subs
|
thisacctq = Acct $ accountNameToAccountRegex a -- includes subs
|
||||||
return $ accountTransactionsReport ropts j q thisacctq
|
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
|
-- brief toJSON definitions included to avoid https://github.com/bos/aeson/issues/290
|
||||||
-- use toEncoding = genericToEncoding defaultOptions instead ?
|
-- use toEncoding = genericToEncoding defaultOptions instead ?
|
||||||
instance ToJSON ClearedStatus where toJSON = genericToJSON defaultOptions
|
instance ToJSON ClearedStatus where toJSON = genericToJSON defaultOptions
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user