diff options
author | Lia Lenckowski <lialenck@protonmail.com> | 2023-08-20 20:00:16 +0200 |
---|---|---|
committer | Lia Lenckowski <lialenck@protonmail.com> | 2023-08-20 20:00:16 +0200 |
commit | 621a91776a6512fc23664e8b2e7ab796ed9ffcd5 (patch) | |
tree | 6b4fe8af6be37bf650e91955c0293118e0c7d89c /src/Main.hs | |
parent | ab8e710d5d9add1374a314f422e8653ccd2ab162 (diff) | |
download | fastbangs-621a91776a6512fc23664e8b2e7ab796ed9ffcd5.tar fastbangs-621a91776a6512fc23664e8b2e7ab796ed9ffcd5.tar.bz2 fastbangs-621a91776a6512fc23664e8b2e7ab796ed9ffcd5.tar.zst |
better config system
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 20 |
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 |