packages feed

hledger-api 1.0 → 1.1

raw patch · 6 files changed

+67/−42 lines, 6 filesdep ~basedep ~hledgerdep ~hledger-lib

Dependency ranges changed: base, hledger, hledger-lib

Files

CHANGES view
@@ -1,5 +1,15 @@ User-visible changes in hledger-api.-See also hledger's change log.+See also the hledger and the project change logs.+++# 1.1 (2016/12/31)++-   serves on 127.0.0.1 by default, --host option added (#432)+    +    Consistent with hledger-web: serves only local requests by default,+    use --host=IPADDR to change this.++-   fixed the version string in command-line help and swagger info   # 1.0 (2016/10/26)
doc/hledger-api.1 view
@@ -1,5 +1,5 @@ -.TH "hledger\-api" "1" "October 2016" "hledger\-api 1.0" "hledger User Manuals"+.TH "hledger\-api" "1" "December 2016" "hledger\-api 1.1" "hledger User Manuals"   @@ -35,11 +35,14 @@ perhaps \f[C]C:/Users/USER/.hledger.journal\f[]). For more about this see hledger(1), hledger_journal(5) etc. .PP-The server listens on port 8001, or another specified with-\f[C]\-p\ PORT\f[].-Note there is no built\-in access control, so you will need to hide+The server listens on IP address 127.0.0.1, accessible only to local+requests, by default.+You can change this with \f[C]\-\-host\f[], eg+\f[C]\-\-host\ 0.0.0.0\f[] to listen on all addresses.+Note there is no other access control, so you will need to hide hledger\-api behind an authenticating proxy if you want to restrict access.+You can change the TCP port (default: 8001) with \f[C]\-p\ PORT\f[]. .PP If invoked as \f[C]hledger\-api\ \-\-swagger\f[], instead of starting a server the API docs will be printed in Swagger 2.0 format.
doc/hledger-api.1.info view
@@ -4,7 +4,7 @@  File: hledger-api.1.info,  Node: Top,  Up: (dir) -hledger-api(1) hledger-api 1.0+hledger-api(1) hledger-api 1.1 ******************************  hledger-api is a simple web API server, intended to support client-side@@ -17,10 +17,12 @@ `C:/Users/USER/.hledger.journal'). For more about this see hledger(1), hledger_journal(5) etc. -   The server listens on port 8001, or another specified with `-p-PORT'. Note there is no built-in access control, so you will need to-hide hledger-api behind an authenticating proxy if you want to restrict-access.+   The server listens on IP address 127.0.0.1, accessible only to local+requests, by default. You can change this with `--host', eg `--host+0.0.0.0' to listen on all addresses. Note there is no other access+control, so you will need to hide hledger-api behind an authenticating+proxy if you want to restrict access. You can change the TCP port+(default: 8001) with `-p PORT'.     If invoked as `hledger-api --swagger', instead of starting a server the API docs will be printed in Swagger 2.0 format.@@ -84,7 +86,7 @@  Tag Table: Node: Top90-Node: OPTIONS1055-Ref: #options1142+Node: OPTIONS1216+Ref: #options1303  End Tag Table
doc/hledger-api.1.txt view
@@ -27,10 +27,12 @@        C:/Users/USER/.hledger.journal).   For  more about this see hledger(1),        hledger_journal(5) etc. -       The server listens on port 8001, or  another  specified  with  -p PORT.-       Note  there  is  no  built-in  access control, so you will need to hide-       hledger-api behind an authenticating proxy  if  you  want  to  restrict-       access.+       The server listens on IP address 127.0.0.1, accessible  only  to  local+       requests,   by   default.    You   can  change  this  with  --host,  eg+       --host 0.0.0.0 to listen on all addresses.   Note  there  is  no  other+       access  control, so you will need to hide hledger-api behind an authen-+       ticating proxy if you want to restrict access.  You can change the  TCP+       port (default: 8001) with -p PORT.         If  invoked  as hledger-api --swagger, instead of starting a server the        API docs will be printed in Swagger 2.0 format.@@ -118,4 +120,4 @@   -hledger-api 1.0                  October 2016                   hledger-api(1)+hledger-api 1.1                  December 2016                  hledger-api(1)
hledger-api.cabal view
@@ -1,9 +1,9 @@--- This file has been generated from package.yaml by hpack version 0.14.0.+-- This file has been generated from package.yaml by hpack version 0.15.0. -- -- see: https://github.com/sol/hpack  name:           hledger-api-version:        1.0+version:        1.1 synopsis:       Web API server for the hledger accounting tool description:    This is a simple web API server for hledger data.                 It comes with a series of simple client-side web app examples.@@ -44,11 +44,11 @@ executable hledger-api   main-is: hledger-api.hs   ghc-options: -threaded-  cpp-options: -DVERSION="1.0"+  cpp-options: -DVERSION="1.1"   build-depends:-      hledger-lib >= 1.0 && < 1.1-    , hledger >= 1.0 && < 1.1-    , base >=4 && <5+      hledger-lib >= 1.1 && < 1.2+    , hledger >= 1.1 && < 1.2+    , base >=4.8 && <5     , aeson     , bytestring     , containers
hledger-api.hs view
@@ -18,6 +18,7 @@ import           Data.Decimal import qualified Data.Map as M import           Data.Proxy+import           Data.String (fromString) import           Data.Swagger import           Data.Text hiding (map,reverse) import           Network.Wai as Wai@@ -34,12 +35,12 @@ import Hledger.Query import Hledger.Cli hiding (Reader, version) -hledgerApiVersion="0.27.98"+hledgerApiVersion="1.1"  -- https://github.com/docopt/docopt.hs#readme doc :: Docopt doc = [docopt|-hledger-api 0.27.98+hledger-api 1.1  Serves hledger data and reports as a JSON web API. @@ -52,16 +53,17 @@   hledger-api -h|--help|--info  Options:-  -f --file FILE  use a different input file-                  (default: $LEDGER_FILE or ~/.hledger.journal)-  -d --static-dir DIR  serve files from a different directory-                  (default: .)-  -p --port PORT  use a different TCP port (default: 8001)-     --version    show version-  -h              show usage-     --help       show manual-     --man        show manual with man-     --info       show manual with info+  -f --file FILE   use a different input file+                   (default: $LEDGER_FILE or ~/.hledger.journal)+  -d --static-dir  DIR  serve files from a different directory+                   (default: .)+     --host IPADDR listen on this IP address (default: 127.0.0.1)+  -p --port PORT   listen on this TCP port (default: 8001)+     --version     show version+  -h               show usage+     --help        show manual+     --man         show manual with man+     --info        show manual with info |]  swaggerSpec :: Swagger@@ -80,7 +82,10 @@   when (isPresent args (longOption "info")) $ runInfoForTopic "api" >> exitSuccess   when (isPresent args (longOption "version")) $ putStrLn hledgerApiVersion >> exitSuccess   when (isPresent args (longOption "swagger")) $ BL8.putStrLn (encode swaggerSpec) >> exitSuccess-  let defp = "8001"+  let+    defh = "127.0.0.1"+    h = getArgWithDefault args defh (longOption "host")+    defp = "8001"   p <- case readMay $ getArgWithDefault args defp (longOption "port") of         Nothing -> exitWithUsage doc         Just n  -> return n@@ -90,14 +95,17 @@   let     defd = "."     d = getArgWithDefault args defd (longOption "static-dir")-  readJournalFile Nothing Nothing True f >>= either error' (serveApi p d f)+  readJournalFile Nothing Nothing True f >>= either error' (serveApi h p d f) -serveApi :: Int -> FilePath -> FilePath -> Journal -> IO ()-serveApi p d f j = do-  printf "Starting web api http://localhost:%d/api/v1 for %s\n" p f-  printf "and file server  http://localhost:%d        for %s/\n" p d+serveApi :: String -> Int -> FilePath -> FilePath -> Journal -> IO ()+serveApi h p d f j = do+  printf "Starting web api http://%s:%d/api/v1 for %s\n" h p f+  printf "and file server  http://%s:%d        for %s/\n" h p d   printf "Press ctrl-c to quit\n"-  Warp.run p $+  let warpsettings = defaultSettings+        & setHost (fromString h)+        & setPort p+  Warp.runSettings warpsettings $     logStdout $     hledgerApiApp d j