{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Rib.Server
( serve,
)
where
import Network.Wai.Application.Static (defaultFileServerSettings, staticApp)
import qualified Network.Wai.Handler.Warp as Warp
import Relude
import Rib.Cli (CliConfig)
import Rib.Log
serve ::
CliConfig ->
Text ->
Int ->
FilePath ->
IO ()
serve cfg host port path = do
logStrLn cfg $ "[Rib] Serving " <> path <> " at http://" <> toString host <> ":" <> show port
Warp.runSettings settings app
where
app = staticApp $ defaultFileServerSettings path
settings =
Warp.setHost (fromString $ toString host)
$ Warp.setPort port
$ Warp.defaultSettings