aboutsummaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/Main.hs b/src/Main.hs
index b5b35a1..3474040 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -54,7 +54,8 @@ instance FromJSON PendingBang where
data Search = Search {
bangState :: BangState,
- sqlPool :: ConnectionPool
+ sqlPool :: ConnectionPool,
+ config :: Config
}
mkYesod "Search" [parseRoutes|
@@ -123,7 +124,8 @@ getOpenSearchR :: Handler TypedContent
getOpenSearchR = do
neverExpires
- resXml <- liftIO . makeOpenSearch =<< lookupGetParam "default"
+ cfg <- config <$> getYesod
+ resXml <- makeOpenSearch cfg <$> lookupGetParam "default"
return $ TypedContent "application/opensearchdescription+xml" $ toContent resXml
postVerdictR :: Bool -> Handler ()
@@ -155,15 +157,13 @@ main :: IO ()
main = runStdoutLoggingT $ withSqlitePool "banger.db" 2 $ \pool -> do
runResourceT $ flip runSqlPool pool $ runMigration migrateAll
- s <- Search
- <$> liftIO initBangState
- <*> pure pool
- sApp <- liftIO $ toWaiApp s -- includes middlewares
+ bs <- liftIO initBangState
+ cfg <- liftIO getConfig
+
+ sApp <- liftIO $ toWaiApp $ Search bs pool cfg -- includes middlewares
- host <- liftIO getHost
- port <- liftIO getPort
let settings = defaultSettings
- & setHost host
- & setPort port
+ & setHost (confHost cfg)
+ & setPort (confPort cfg)
liftIO $ runSettings settings sApp