we have a running webserver (nothing tested)
This commit is contained in:
parent
fecda5bd45
commit
e4339fb38d
4 changed files with 47 additions and 2 deletions
15
app/Main.hs
15
app/Main.hs
|
@ -1,6 +1,17 @@
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import Lib
|
-- TODO:
|
||||||
|
-- We need some logic to compile with different backends. Right now we only
|
||||||
|
-- support warp. But a (fast) cgi backend would be nice too.
|
||||||
|
|
||||||
|
-- TODO:
|
||||||
|
-- We need some way too configure things, like the port we run on.
|
||||||
|
-- see Network.Wai.Handler.Warp.Settings and Network.Wai.Handler.Warp.runSettings
|
||||||
|
import WaiApp
|
||||||
|
import Control.Concurrent.MVar
|
||||||
|
import Network.Wai.Handler.Warp
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = someFunc
|
main = do
|
||||||
|
serverState <- newMVar newServerState
|
||||||
|
run 8080 $ waiApplication serverState
|
||||||
|
|
17
app/WaiApp.hs
Normal file
17
app/WaiApp.hs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
|
module WaiApp (waiApplication, WSA.newServerState, WSA.ServerState) where
|
||||||
|
|
||||||
|
import qualified WebSocketApp as WSA
|
||||||
|
import qualified Network.WebSockets as WS
|
||||||
|
import Network.Wai.Handler.WebSockets
|
||||||
|
import Network.Wai
|
||||||
|
import Network.HTTP.Types
|
||||||
|
import Control.Concurrent.MVar
|
||||||
|
|
||||||
|
waiApplication :: MVar WSA.ServerState -> Application
|
||||||
|
waiApplication serverState = websocketsOr WS.defaultConnectionOptions (WSA.application serverState) clientServer
|
||||||
|
|
||||||
|
-- this should serve the webclient see Network.Wai.responseFile
|
||||||
|
clientServer :: Application
|
||||||
|
clientServer _ respond = respond $ responseLBS status404 [] "No webclient implemented (Franzi essen ?? -- Emma)"
|
|
@ -29,6 +29,10 @@ dependencies:
|
||||||
- websockets
|
- websockets
|
||||||
- bytestring
|
- bytestring
|
||||||
- containers
|
- containers
|
||||||
|
- wai
|
||||||
|
- wai-websockets
|
||||||
|
- http-types
|
||||||
|
- warp
|
||||||
|
|
||||||
library:
|
library:
|
||||||
source-dirs: src
|
source-dirs: src
|
||||||
|
|
|
@ -35,16 +35,21 @@ library
|
||||||
, base >=4.7 && <5
|
, base >=4.7 && <5
|
||||||
, bytestring
|
, bytestring
|
||||||
, containers
|
, containers
|
||||||
|
, http-types
|
||||||
, text
|
, text
|
||||||
, tickLeiste
|
, tickLeiste
|
||||||
, tickLeiste-aeson
|
, tickLeiste-aeson
|
||||||
, uuid
|
, uuid
|
||||||
|
, wai
|
||||||
|
, wai-websockets
|
||||||
|
, warp
|
||||||
, websockets
|
, websockets
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
executable tickLeisteServer
|
executable tickLeisteServer
|
||||||
main-is: Main.hs
|
main-is: Main.hs
|
||||||
other-modules:
|
other-modules:
|
||||||
|
WaiApp
|
||||||
WebSocketApp
|
WebSocketApp
|
||||||
Paths_tickLeisteServer
|
Paths_tickLeisteServer
|
||||||
hs-source-dirs:
|
hs-source-dirs:
|
||||||
|
@ -55,11 +60,15 @@ executable tickLeisteServer
|
||||||
, base >=4.7 && <5
|
, base >=4.7 && <5
|
||||||
, bytestring
|
, bytestring
|
||||||
, containers
|
, containers
|
||||||
|
, http-types
|
||||||
, text
|
, text
|
||||||
, tickLeiste
|
, tickLeiste
|
||||||
, tickLeiste-aeson
|
, tickLeiste-aeson
|
||||||
, tickLeisteServer
|
, tickLeisteServer
|
||||||
, uuid
|
, uuid
|
||||||
|
, wai
|
||||||
|
, wai-websockets
|
||||||
|
, warp
|
||||||
, websockets
|
, websockets
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
@ -76,10 +85,14 @@ test-suite tickLeisteServer-test
|
||||||
, base >=4.7 && <5
|
, base >=4.7 && <5
|
||||||
, bytestring
|
, bytestring
|
||||||
, containers
|
, containers
|
||||||
|
, http-types
|
||||||
, text
|
, text
|
||||||
, tickLeiste
|
, tickLeiste
|
||||||
, tickLeiste-aeson
|
, tickLeiste-aeson
|
||||||
, tickLeisteServer
|
, tickLeisteServer
|
||||||
, uuid
|
, uuid
|
||||||
|
, wai
|
||||||
|
, wai-websockets
|
||||||
|
, warp
|
||||||
, websockets
|
, websockets
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue