mirror of
https://github.com/srid/ema.git
synced 2024-11-26 06:03:50 +03:00
api: Rename to EmaWebSocketOptions
This commit is contained in:
parent
870f6648a1
commit
a533a63811
@ -18,7 +18,7 @@ import Ema
|
|||||||
import Ema.CLI qualified as CLI
|
import Ema.CLI qualified as CLI
|
||||||
import Ema.Route.Generic.TH
|
import Ema.Route.Generic.TH
|
||||||
import Ema.Route.Lib.Extra.PandocRoute qualified as Pandoc
|
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 Ema.Server.WebSocket.Options (EmaWsHandler (..), wsClientJS)
|
||||||
import Network.WebSockets qualified as WS
|
import Network.WebSockets qualified as WS
|
||||||
import Optics.Core ((%))
|
import Optics.Core ((%))
|
||||||
@ -127,8 +127,8 @@ runWithFollow input = do
|
|||||||
let cfg = SiteConfig cli followServerOptions
|
let cfg = SiteConfig cli followServerOptions
|
||||||
void $ snd <$> runSiteWith @Route cfg input
|
void $ snd <$> runSiteWith @Route cfg input
|
||||||
|
|
||||||
followServerOptions :: EmaServerOptions Route
|
followServerOptions :: EmaWebSocketOptions Route
|
||||||
followServerOptions = EmaServerOptions wsClientJS followServerHandler
|
followServerOptions = EmaWebSocketOptions wsClientJS followServerHandler
|
||||||
|
|
||||||
followServerHandler :: EmaWsHandler Route
|
followServerHandler :: EmaWsHandler Route
|
||||||
followServerHandler = EmaWsHandler handle
|
followServerHandler = EmaWsHandler handle
|
||||||
|
@ -24,7 +24,7 @@ import System.Directory (getCurrentDirectory)
|
|||||||
|
|
||||||
data SiteConfig r = SiteConfig
|
data SiteConfig r = SiteConfig
|
||||||
{ siteConfigCli :: CLI.Cli
|
{ siteConfigCli :: CLI.Cli
|
||||||
, siteConfigServerOpts :: Server.EmaServerOptions r
|
, siteConfigServerOpts :: Server.EmaWebSocketOptions r
|
||||||
}
|
}
|
||||||
|
|
||||||
instance Default (SiteConfig r) where
|
instance Default (SiteConfig r) where
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
module Ema.Server (
|
module Ema.Server (
|
||||||
EmaServerOptions (..),
|
EmaWebSocketOptions (..),
|
||||||
runServerWithWebSocketHotReload,
|
runServerWithWebSocketHotReload,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ import Ema.CLI (Host (unHost))
|
|||||||
import Ema.Route.Class (IsRoute (RouteModel))
|
import Ema.Route.Class (IsRoute (RouteModel))
|
||||||
import Ema.Server.HTTP (httpApp)
|
import Ema.Server.HTTP (httpApp)
|
||||||
import Ema.Server.WebSocket (wsApp)
|
import Ema.Server.WebSocket (wsApp)
|
||||||
import Ema.Server.WebSocket.Options (EmaServerOptions (..))
|
import Ema.Server.WebSocket.Options (EmaWebSocketOptions (..))
|
||||||
import Ema.Site (EmaStaticSite)
|
import Ema.Site (EmaStaticSite)
|
||||||
import Network.Wai qualified as Wai
|
import Network.Wai qualified as Wai
|
||||||
import Network.Wai.Handler.Warp (Port)
|
import Network.Wai.Handler.Warp (Port)
|
||||||
@ -29,7 +29,7 @@ runServerWithWebSocketHotReload ::
|
|||||||
, IsRoute r
|
, IsRoute r
|
||||||
, EmaStaticSite r
|
, EmaStaticSite r
|
||||||
) =>
|
) =>
|
||||||
EmaServerOptions r ->
|
EmaWebSocketOptions r ->
|
||||||
Host ->
|
Host ->
|
||||||
Maybe Port ->
|
Maybe Port ->
|
||||||
LVar (RouteModel r) ->
|
LVar (RouteModel r) ->
|
||||||
@ -43,8 +43,8 @@ runServerWithWebSocketHotReload opts host mport model = do
|
|||||||
app =
|
app =
|
||||||
WaiWs.websocketsOr
|
WaiWs.websocketsOr
|
||||||
WS.defaultConnectionOptions
|
WS.defaultConnectionOptions
|
||||||
(wsApp @r logger model $ emaServerWsHandler opts)
|
(wsApp @r logger model $ emaWebSocketServerHandler opts)
|
||||||
(httpApp @r logger model $ emaServerShim opts)
|
(httpApp @r logger model $ emaWebSocketClientShim opts)
|
||||||
banner port = do
|
banner port = do
|
||||||
logInfoNS "ema" "==============================================="
|
logInfoNS "ema" "==============================================="
|
||||||
logInfoNS "ema" $ "Ema live server RUNNING: http://" <> unHost host <> ":" <> show port
|
logInfoNS "ema" $ "Ema live server RUNNING: http://" <> unHost host <> ":" <> show port
|
||||||
|
@ -36,14 +36,14 @@ instance Default (EmaWsHandler r) where
|
|||||||
where
|
where
|
||||||
log lvl (t :: Text) = logWithoutLoc "ema.ws" lvl t
|
log lvl (t :: Text) = logWithoutLoc "ema.ws" lvl t
|
||||||
|
|
||||||
data EmaServerOptions r = EmaServerOptions
|
data EmaWebSocketOptions r = EmaWebSocketOptions
|
||||||
{ emaServerShim :: LByteString
|
{ emaWebSocketClientShim :: LByteString
|
||||||
, emaServerWsHandler :: EmaWsHandler r
|
, emaWebSocketServerHandler :: EmaWsHandler r
|
||||||
}
|
}
|
||||||
|
|
||||||
instance Default (EmaServerOptions r) where
|
instance Default (EmaWebSocketOptions r) where
|
||||||
def =
|
def =
|
||||||
EmaServerOptions wsClientJS def
|
EmaWebSocketOptions wsClientJS def
|
||||||
|
|
||||||
-- Browser-side JavaScript code for interacting with the Haskell server
|
-- Browser-side JavaScript code for interacting with the Haskell server
|
||||||
wsClientJS :: LByteString
|
wsClientJS :: LByteString
|
||||||
|
Loading…
Reference in New Issue
Block a user