summaryrefslogtreecommitdiff
path: root/Handler
diff options
context:
space:
mode:
authorDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2016-05-27 16:00:00 -0400
committerDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2018-09-26 18:11:11 -0400
commita1a17acb326020f1b57f587230cb439e901784df (patch)
tree358a1ea916a242609a981ff46e2a6814a2208cec /Handler
parentf1a294e5ddb8ae0ccdcef1a12561e603ff996cfe (diff)
Ported to Debian jessie
Most of the churn here comes from rebasing the Yesod boilerplate.
Diffstat (limited to 'Handler')
-rw-r--r--Handler/Journal.hs10
-rw-r--r--Handler/Register.hs10
2 files changed, 6 insertions, 14 deletions
diff --git a/Handler/Journal.hs b/Handler/Journal.hs
index dc68fa5..aa9d18c 100644
--- a/Handler/Journal.hs
+++ b/Handler/Journal.hs
@@ -25,19 +25,15 @@ import qualified Data.Map as Map
typeCsv :: ContentType
typeCsv = "text/csv; charset=utf-8"
-newtype RepCsv = RepCsv Content
-instance HasReps RepCsv where
- chooseRep (RepCsv c) _ = return (typeCsv, c)
-
-getJournalR :: JReportType -> Text -> Handler RepCsv
+getJournalR :: JReportType -> Text -> Handler TypedContent
getJournalR jrt ledger = do
ledgers <- fmap hledgerConfig getYesod
case Map.lookup ledger ledgers of
Nothing -> notFound
Just fn -> do
csv <- liftIO $ (jReport jrt) fn
- setHeader "Content-Disposition" (T.concat ["attachment; filename=", ledger, "-", (T.pack . show) jrt, ".csv"])
- return $ RepCsv $ toContent csv
+ addHeader "Content-Disposition" (T.concat ["attachment; filename=", ledger, "-", (T.pack . show) jrt, ".csv"])
+ sendResponse (typeCsv, toContent csv)
where
jReport PandL = pAndL
jReport Assets = assets
diff --git a/Handler/Register.hs b/Handler/Register.hs
index 26e38a2..2718036 100644
--- a/Handler/Register.hs
+++ b/Handler/Register.hs
@@ -25,16 +25,12 @@ import qualified Data.Map as Map
typeCsv :: ContentType
typeCsv = "text/csv; charset=utf-8"
-newtype RepCsv = RepCsv Content
-instance HasReps RepCsv where
- chooseRep (RepCsv c) _ = return (typeCsv, c)
-
-getRegisterR :: Text -> Handler RepCsv
+getRegisterR :: Text -> Handler TypedContent
getRegisterR ledger = do
ledgers <- fmap hledgerConfig getYesod
case Map.lookup ledger ledgers of
Nothing -> notFound
Just fn -> do
csv <- liftIO $ convertJournalToRegisterCSV fn
- setHeader "Content-Disposition" (T.concat ["attachment; filename=", ledger, ".csv"])
- return $ RepCsv $ toContent csv
+ addHeader "Content-Disposition" (T.concat ["attachment; filename=", ledger, ".csv"])
+ sendResponse (typeCsv, toContent csv)