aboutsummaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/Main.hs b/src/Main.hs
index a59b38a..7d3a331 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -57,27 +57,25 @@ instance YesodPersist Search where
getHomeR :: Handler TypedContent
getHomeR = do
cacheSeconds $ 60 * 60 * 24 * 7
- return $ TypedContent typeHtml $ toContent ($(embedFile "build/index.html"))
+ respond typeHtml ($(embedFile "build/index.html"))
getBundleR :: Handler TypedContent
getBundleR = do
cacheSeconds $ 60 * 60 * 24 * 7
noEmbed <- confNoEmbed . config <$> getYesod
- bundle <- liftIO $ bool
- (pure $ toContent ($(embedFile "build/bundle.js")))
- (toContent <$> readFile "../build/bundle.js")
- noEmbed
- return $ TypedContent typeJavascript bundle
+
+ respond typeJavascript =<< if noEmbed
+ then liftIO $ BS.readFile "../build/bundle.js"
+ else pure ($(embedFile "build/bundle.js"))
getStyleR :: Handler TypedContent
getStyleR = do
cacheSeconds $ 60 * 60 * 24 * 7
noEmbed <- confNoEmbed . config <$> getYesod
- stylesheet <- liftIO $ bool
- (pure $ toContent ($(embedFile "build/style.css")))
- (toContent <$> readFile "../build/style.css")
- noEmbed
- return $ TypedContent typeCss stylesheet
+
+ respond typeCss =<< if noEmbed
+ then liftIO $ BS.readFile "../build/style.css"
+ else pure ($(embedFile "build/style.css"))
getBangsR :: Handler TypedContent
getBangsR = do
@@ -95,7 +93,7 @@ getBangsR = do
_ -> do
liftIO $ getBangsJSON st
- return $ TypedContent typeJson $ toContent bs
+ respond typeJson bs
postSubmitR :: Handler ()
postSubmitR = do
@@ -111,7 +109,7 @@ getOpenSearchR = do
cfg <- config <$> getYesod
resXml <- makeOpenSearch cfg <$> lookupGetParam "default"
- return $ TypedContent "application/opensearchdescription+xml" $ toContent resXml
+ respond "application/opensearchdescription+xml" resXml
postVerdictR :: Bool -> Handler ()
postVerdictR b = do