@@ -66,38 +66,40 @@ backend
66 :: ( Universe (R route) --TODO: This seems wrong - should be Universe (Some route)
66 :: ( Universe (R route) --TODO: This seems wrong - should be Universe (Some route)
67 , OrdTag route Identity
67 , OrdTag route Identity
68 , ShowTag route Identity
68 , ShowTag route Identity
69+ , check ~ Either Text --TODO: Replace with MonadError Text check
70 => BackendConfig route
71 => BackendConfig route
71− -> IO ()
72+ -> check (IO ())
72backend cfg = do
73backend cfg = do
74+ getRequestRoute <- checkGetRequestRoute $ _backendConfig_routeEncoder cfg --TODO: Report error better
73− -- Make output more legible by decreasing the likelihood of output from
76+ -- Make output more legible by decreasing the likelihood of output from
74− -- multiple threads being interleaved
77+ -- multiple threads being interleaved
75− hSetBuffering stdout LineBuffering
78+ hSetBuffering stdout LineBuffering
76− hSetBuffering stderr LineBuffering
79+ hSetBuffering stderr LineBuffering
78− -- Get the web server configuration from the command line
81+ -- Get the web server configuration from the command line
79− cmdLineConf <- commandLineConfig defaultConfig
82+ cmdLineConf <- commandLineConfig defaultConfig
80− let httpConf = cmdLineConf
83+ let httpConf = cmdLineConf
81− { accessLog = Just $ ConfigIoLog BSC8.putStrLn
84+ { accessLog = Just $ ConfigIoLog BSC8.putStrLn
82− , errorLog = Just $ ConfigIoLog BSC8.putStrLn
85+ , errorLog = Just $ ConfigIoLog BSC8.putStrLn
84− let Right getRequestRoute = checkGetRequestRoute $ _backendConfig_routeEncoder cfg --TODO: Report error better
85− -- Start the web server
86− httpServe httpConf $ do
87− let staticAssets = StaticAssets
88− { _staticAssets_processed = "static.jsexe.assets"
89− , _staticAssets_unprocessed = "static.jsexe"
91− frontendApp = GhcjsApp
87+ -- Start the web server
88+ httpServe httpConf $ do
92− { _ghcjsApp_compiled = StaticAssets
89+ let staticAssets = StaticAssets
93− { _staticAssets_processed = "frontend.jsexe.assets"
90+ { _staticAssets_processed = "static.jsexe.assets"
94− , _staticAssets_unprocessed = "frontend.jsexe"
91+ , _staticAssets_unprocessed = "static.jsexe"
93+ frontendApp = GhcjsApp
94+ { _ghcjsApp_compiled = StaticAssets
95+ { _staticAssets_processed = "frontend.jsexe.assets"
96+ , _staticAssets_unprocessed = "frontend.jsexe"
96− , _ghcjsApp_value = _backendConfig_frontend cfg
98+ , _ghcjsApp_value = _backendConfig_frontend cfg
98− getRequestRoute >>= \case
100+ getRequestRoute >>= \case
99− Left e -> writeText e
101+ Left e -> writeText e
100− Right r -> serveObeliskRoute staticAssets frontendApp r
102+ Right r -> serveObeliskRoute staticAssets frontendApp r
102checkGetRequestRoute :: (MonadSnap m, Monad check, MonadError Text parse) => Encoder check parse route PageName -> check (m (parse route))
104checkGetRequestRoute :: (MonadSnap m, Monad check, MonadError Text parse) => Encoder check parse route PageName -> check (m (parse route))
103checkGetRequestRoute routeEncoder = do
105checkGetRequestRoute routeEncoder = do