{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-orphans #-}


-- | small web frontend
module SnelstartImport.Web
  ( webMain
  )
where

import SnelstartImport.Options
import Yesod.Core.Dispatch(mkYesodDispatch)
import Yesod.Core(toWaiApp)
import Network.Wai.Handler.Warp(run)
import SnelstartImport.Web.Routes
import SnelstartImport.Web.Handler

mkYesodDispatch "App" resourcesApp


webMain :: WebOptions -> IO ()
webMain :: WebOptions -> IO ()
webMain WebOptions
options = do
  String -> IO ()
putStrLn (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ String
"listening on port " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (WebOptions -> Int
webPort WebOptions
options)
  Application
waiApp <- App -> IO Application
forall site. YesodDispatch site => site -> IO Application
toWaiApp App
App
  Int -> Application -> IO ()
run (WebOptions -> Int
webPort WebOptions
options) Application
waiApp