1
1
mirror of https://github.com/srid/ema.git synced 2024-11-22 12:33:18 +03:00

api: Rename to EmaWebSocketOptions

This commit is contained in:
Sridhar Ratnakumar 2023-12-11 17:11:25 -05:00
parent 870f6648a1
commit a533a63811
4 changed files with 14 additions and 14 deletions

View File

@ -18,7 +18,7 @@ import Ema
import Ema.CLI qualified as CLI
import Ema.Route.Generic.TH
import Ema.Route.Lib.Extra.PandocRoute qualified as Pandoc
import Ema.Server (EmaServerOptions (..))
import Ema.Server (EmaWebSocketOptions (..))
import Ema.Server.WebSocket.Options (EmaWsHandler (..), wsClientJS)
import Network.WebSockets qualified as WS
import Optics.Core ((%))
@ -127,8 +127,8 @@ runWithFollow input = do
let cfg = SiteConfig cli followServerOptions
void $ snd <$> runSiteWith @Route cfg input
followServerOptions :: EmaServerOptions Route
followServerOptions = EmaServerOptions wsClientJS followServerHandler
followServerOptions :: EmaWebSocketOptions Route
followServerOptions = EmaWebSocketOptions wsClientJS followServerHandler
followServerHandler :: EmaWsHandler Route
followServerHandler = EmaWsHandler handle

View File

@ -24,7 +24,7 @@ import System.Directory (getCurrentDirectory)
data SiteConfig r = SiteConfig
{ siteConfigCli :: CLI.Cli
, siteConfigServerOpts :: Server.EmaServerOptions r
, siteConfigServerOpts :: Server.EmaWebSocketOptions r
}
instance Default (SiteConfig r) where

View File

@ -1,5 +1,5 @@
module Ema.Server (
EmaServerOptions (..),
EmaWebSocketOptions (..),
runServerWithWebSocketHotReload,
) where
@ -9,7 +9,7 @@ import Ema.CLI (Host (unHost))
import Ema.Route.Class (IsRoute (RouteModel))
import Ema.Server.HTTP (httpApp)
import Ema.Server.WebSocket (wsApp)
import Ema.Server.WebSocket.Options (EmaServerOptions (..))
import Ema.Server.WebSocket.Options (EmaWebSocketOptions (..))
import Ema.Site (EmaStaticSite)
import Network.Wai qualified as Wai
import Network.Wai.Handler.Warp (Port)
@ -29,7 +29,7 @@ runServerWithWebSocketHotReload ::
, IsRoute r
, EmaStaticSite r
) =>
EmaServerOptions r ->
EmaWebSocketOptions r ->
Host ->
Maybe Port ->
LVar (RouteModel r) ->
@ -43,8 +43,8 @@ runServerWithWebSocketHotReload opts host mport model = do
app =
WaiWs.websocketsOr
WS.defaultConnectionOptions
(wsApp @r logger model $ emaServerWsHandler opts)
(httpApp @r logger model $ emaServerShim opts)
(wsApp @r logger model $ emaWebSocketServerHandler opts)
(httpApp @r logger model $ emaWebSocketClientShim opts)
banner port = do
logInfoNS "ema" "==============================================="
logInfoNS "ema" $ "Ema live server RUNNING: http://" <> unHost host <> ":" <> show port

View File

@ -36,14 +36,14 @@ instance Default (EmaWsHandler r) where
where
log lvl (t :: Text) = logWithoutLoc "ema.ws" lvl t
data EmaServerOptions r = EmaServerOptions
{ emaServerShim :: LByteString
, emaServerWsHandler :: EmaWsHandler r
data EmaWebSocketOptions r = EmaWebSocketOptions
{ emaWebSocketClientShim :: LByteString
, emaWebSocketServerHandler :: EmaWsHandler r
}
instance Default (EmaServerOptions r) where
instance Default (EmaWebSocketOptions r) where
def =
EmaServerOptions wsClientJS def
EmaWebSocketOptions wsClientJS def
-- Browser-side JavaScript code for interacting with the Haskell server
wsClientJS :: LByteString