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