summaryrefslogtreecommitdiff
path: root/app/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Main.hs')
-rw-r--r--app/Main.hs13
1 files changed, 6 insertions, 7 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 433ad8d..7ca801a 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -5,7 +5,6 @@ import qualified Control.Exception as E
import Control.Monad (unless, forever, void)
import qualified Data.ByteString as S
-import qualified Data.Text as T
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import Network.Socket
@@ -13,26 +12,26 @@ import Network.Socket.ByteString (recv, sendAll)
import Web.Utils
import Web.Response
-import Web.Router
+import qualified Web.Router
import Routes
-import Settings (host, port)
+import qualified Settings
main :: IO ()
main = do
- let hostStr = case host of
+ let hostStr = case Settings.host of
Just smt -> smt
Nothing -> "0.0.0.0"
- putStrLn $ "Server launched on " ++ hostStr ++ ":" ++ port
- runTCPServer host port talk
+ putStrLn $ "Server launched on " ++ hostStr ++ ":" ++ Settings.port
+ runTCPServer Settings.host Settings.port talk
where
talk s = do
msg <- recv s 1024
putStrLn "Got request"
unless (S.null msg) $ do
let (request, _, _) = parseHttp $ decodeUtf8 msg
- response <- resolve routesTable $ request
+ response <- Web.Router.resolve routesTable $ request
sendAll s $ encodeUtf8 (formResponse response)
runTCPServer :: Maybe HostName -> ServiceName -> (Socket -> IO a) -> IO a