mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-07 21:15:19 +03:00
web: /version provides hledger version string as JSON (#1152)
This commit is contained in:
parent
f2b9ac2af1
commit
fd200a85af
@ -7,7 +7,8 @@
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
module Hledger.Web.Handler.MiscR
|
||||
( getAccountnamesR
|
||||
( getVersionR
|
||||
, getAccountnamesR
|
||||
, getTransactionsR
|
||||
, getPricesR
|
||||
, getCommoditiesR
|
||||
@ -25,6 +26,7 @@ import qualified Data.Text as T
|
||||
import Yesod.Default.Handlers (getFaviconR, getRobotsR)
|
||||
|
||||
import Hledger
|
||||
import Hledger.Cli.Version (version)
|
||||
import Hledger.Web.Import
|
||||
import Hledger.Web.Widget.Common (journalFile404)
|
||||
|
||||
@ -53,6 +55,13 @@ getDownloadR f = do
|
||||
|
||||
-- hledger-web equivalents of the old hledger-api's handlers
|
||||
|
||||
getVersionR :: Handler TypedContent
|
||||
getVersionR = do
|
||||
VD{caps} <- getViewData
|
||||
when (CapView `notElem` caps) (permissionDenied "Missing the 'view' capability")
|
||||
selectRep $ do
|
||||
provideJson $ version
|
||||
|
||||
getAccountnamesR :: Handler TypedContent
|
||||
getAccountnamesR = do
|
||||
VD{caps, j} <- getViewData
|
||||
|
@ -12,6 +12,7 @@
|
||||
/upload/#FilePath UploadR GET POST
|
||||
/download/#FilePath DownloadR GET
|
||||
|
||||
/version VersionR GET
|
||||
/accountnames AccountnamesR GET
|
||||
/transactions TransactionsR GET
|
||||
/prices PricesR GET
|
||||
|
@ -215,6 +215,7 @@ $ hledger-web -f examples/sample.journal --serve-api
|
||||
You can get JSON data from these routes:
|
||||
|
||||
```
|
||||
/version
|
||||
/accountnames
|
||||
/transactions
|
||||
/prices
|
||||
|
Loading…
Reference in New Issue
Block a user