diff options
author | Lia Lenckowski <lialenck@protonmail.com> | 2023-07-25 20:59:19 +0200 |
---|---|---|
committer | Lia Lenckowski <lialenck@protonmail.com> | 2023-07-25 20:59:19 +0200 |
commit | 6eb4dcd414e220ca95e4442a1a21cd448e8035ce (patch) | |
tree | 6de77dd1cbd76413af0c5edbf112eb797c64cb96 /src/Main.hs | |
parent | 46a5542a437f9d4cd64b2444b0b3b5662fbfff0c (diff) | |
download | fastbangs-6eb4dcd414e220ca95e4442a1a21cd448e8035ce.tar fastbangs-6eb4dcd414e220ca95e4442a1a21cd448e8035ce.tar.bz2 fastbangs-6eb4dcd414e220ca95e4442a1a21cd448e8035ce.tar.zst |
make some settings configurable through environment variables
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Main.hs b/src/Main.hs index 5ab2322..2599df5 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -4,7 +4,7 @@ module Main (main) where import Yesod -import Network.Wai.Handler.Warp +import Network.Wai.Handler.Warp hiding (getPort, getHost) import Data.Function ((&)) import Data.Functor ((<&>)) @@ -52,23 +52,25 @@ postSubmitR = return "TODO" getOpenSearchR :: Handler TypedContent getOpenSearchR = do + baseUrl <- liftIO getBaseUrl url <- lookupGetParam "default" <&> \case Nothing -> baseUrl <> "/#{searchTerms}" Just b -> baseUrl <> "/#" <> b <> "#{searchTerms}" - return - $ TypedContent "application/opensearchdescription+xml" - $ toContent - $ makeOpenSearch url + liftIO $ + TypedContent "application/opensearchdescription+xml" + . toContent + <$> makeOpenSearch url main :: IO () main = do s <- Search <$> initBangState - sApp <- toWaiApp s -- includes middlewares + + host <- getHost + port <- getPort let settings = defaultSettings - -- currently, "*" seems to bind only to ipv4 while "*6" binds to both - & setHost "*6" - & setPort 20546 + & setHost host + & setPort port runSettings settings sApp |