{-# LANGUAGE AllowAmbiguousTypes #-}
module IHP.ServerSideComponent.RouterFunctions where
import IHP.Prelude
import IHP.ServerSideComponent.Types
import qualified Data.Typeable as Typeable
import qualified Data.ByteString.Char8 as ByteString
import IHP.RouterSupport
import qualified Prelude
import IHP.ServerSideComponent.Controller.ComponentsController ()
import Data.Aeson
import IHP.ControllerSupport
import IHP.ApplicationContext
routeComponent :: forall component controller application.
( Typeable component
, Component component controller
, FromJSON controller
, InitControllerContext application
, Typeable application
, ?application :: application
, ?applicationContext :: IHP.ApplicationContext.ApplicationContext
, ?context :: RequestContext
) => RouteParser
routeComponent :: forall component controller application.
(Typeable component, Component component controller,
FromJSON controller, InitControllerContext application,
Typeable application, ?application::application,
?applicationContext::ApplicationContext,
?context::RequestContext) =>
RouteParser
routeComponent = forall webSocketApp application.
(WSApp webSocketApp, InitControllerContext application,
?application::application, ?applicationContext::ApplicationContext,
?context::RequestContext, Typeable application,
Typeable webSocketApp) =>
ByteString -> RouteParser
webSocketAppWithCustomPath @(ComponentsController component) @application (ByteString
"SSC/" ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString
typeName)
where
typeName :: ByteString
typeName :: ByteString
typeName = component -> TypeRep
forall a. Typeable a => a -> TypeRep
Typeable.typeOf (Text -> component
forall a. Text -> a
error Text
"unreachable" :: component)
TypeRep -> (TypeRep -> String) -> String
forall {t1} {t2}. t1 -> (t1 -> t2) -> t2
|> TypeRep -> String
forall a. Show a => a -> String
Prelude.show
String -> (String -> ByteString) -> ByteString
forall {t1} {t2}. t1 -> (t1 -> t2) -> t2
|> String -> ByteString
ByteString.pack