jitsi-roomsv2/backend/src/WebServer.hs

26 lines
719 B
Haskell
Raw Normal View History

2023-01-15 18:26:41 +01:00
module WebServer (runWebServer) where
import ClassyPrelude
import Network.HTTP.Types
import Network.Wai
import Network.Wai.Handler.Warp (run)
import WebSocket (ServerState, broadcast)
2023-01-22 13:05:50 +01:00
-- todo: use ReaderT instead of curring the state
-- then add a MVar for storing the room Data, including users that are not in any room yet
2023-01-15 18:26:41 +01:00
app :: MVar ServerState -> Application
2023-01-22 13:05:50 +01:00
app state req respond = do
2023-01-15 18:26:41 +01:00
putStrLn "I've done some IO here"
2023-01-22 13:05:50 +01:00
withMVar state $ \currenState -> broadcast "body of req" currenState
2023-01-15 18:26:41 +01:00
respond $
responseLBS
status200
[("Content-Type", "text/plain")]
2023-01-22 13:05:50 +01:00
""
2023-01-15 18:26:41 +01:00
runWebServer :: MVar ServerState -> IO ()
runWebServer state = do
2023-01-22 13:05:50 +01:00
putStrLn "http://localhost:8080/"
2023-01-15 18:26:41 +01:00
run 8080 $ app state