@@ -94,17 +94,12 @@ run port serveStaticAsset backend frontend = do
94runServeAsset :: FilePath -> [Text] -> Snap ()
94runServeAsset :: FilePath -> [Text] -> Snap ()
95runServeAsset rootPath = Snap.serveAsset "" rootPath . T.unpack . T.intercalate "/"
95runServeAsset rootPath = Snap.serveAsset "" rootPath . T.unpack . T.intercalate "/"
97−getConfigRoute :: Map Text Text -> IO (Maybe URI)
97+getConfigRoute :: Map Text Text -> Either Text URI
98getConfigRoute configs = case Map.lookup "common/route" configs of
98getConfigRoute configs = case Map.lookup "common/route" configs of
99 Just r -> case URI.mkURI $ T.strip r of
99 Just r -> case URI.mkURI $ T.strip r of
100− Just route -> pure $ Just route
100+ Just route -> Right route
101− Nothing -> do
101+ Nothing -> Left $ "Couldn't parse route as URI; value read was: " <> T.pack (show r)
102− putStrLn $ "Route is invalid: " <> show r
102+ Nothing -> Left $ "Couldn't find config file common/route; it should contain the site's canonical root URI" <> T.pack (show $ Map.keys configs)
104− Nothing -> pure Nothing
107−defAppUri = fromMaybe (error "defAppUri") $ URI.mkURI "http://127.0.0.1:8000"
110 :: RunConfig
105 :: RunConfig
@@ -113,7 +108,7 @@ runWidget
113 -> Encoder Identity Identity (R (Sum backendRoute (ObeliskRoute route))) PageName
108 -> Encoder Identity Identity (R (Sum backendRoute (ObeliskRoute route))) PageName
115runWidget conf configs frontend validFullEncoder = do
110runWidget conf configs frontend validFullEncoder = do
116− uri <- fromMaybe defAppUri <$> getConfigRoute configs
111+ uri <- either (fail . T.unpack) pure $ getConfigRoute configs
117 let port = fromIntegral $ fromMaybe 80 $ uri ^? uriAuthority . _Right . authPort . _Just
112 let port = fromIntegral $ fromMaybe 80 $ uri ^? uriAuthority . _Right . authPort . _Just
118 redirectHost = _runConfig_redirectHost conf
113 redirectHost = _runConfig_redirectHost conf
119 redirectPort = _runConfig_redirectPort conf
114 redirectPort = _runConfig_redirectPort conf