25 lines
714 B
Haskell
25 lines
714 B
Haskell
{-# LANGUAGE OverloadedStrings, NamedFieldPuns #-}
|
|
|
|
import Application
|
|
import Breve.Settings
|
|
import Breve.UrlTable
|
|
|
|
import Web.Spock.Safe
|
|
import Network.Wai.Handler.WarpTLS (runTLS, TLSSettings)
|
|
import Network.Wai.Handler.Warp (defaultSettings, setPort)
|
|
|
|
runBreve :: TLSSettings -> Int -> SpockT IO () -> IO ()
|
|
runBreve tls port spock =
|
|
spockAsApp (spockT id spock) >>= runTLS tls settings
|
|
where settings = setPort port defaultSettings
|
|
|
|
main :: IO ()
|
|
main = do
|
|
AppSettings { bindUrl
|
|
, bindPort
|
|
, urlTable
|
|
, tlsSetts } <- settings
|
|
table <- load urlTable
|
|
putStrLn ("Serving on " ++ bindUrl)
|
|
runBreve tlsSetts bindPort (app bindUrl table)
|
|
|