summaryrefslogtreecommitdiff
path: root/Handler
diff options
context:
space:
mode:
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)