summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuebinm2022-04-05 23:22:33 +0200
committerstuebinm2022-04-05 23:22:33 +0200
commit833186af823d334c464a204133b3db5e5f19ccce (patch)
treeb79ae49d7204fe688045a99ea569efd6f9750fad
parent72760b0fe1afcb23acfbefd88e27f052f81f4e21 (diff)
cwality-maps: change routes
otherwise workadventure & the deployment got confused
Diffstat (limited to '')
-rw-r--r--cwality-maps/Main.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/cwality-maps/Main.hs b/cwality-maps/Main.hs
index 39723f4..3f383cd 100644
--- a/cwality-maps/Main.hs
+++ b/cwality-maps/Main.hs
@@ -78,10 +78,11 @@ instance FromHttpApiData MapParams where
-- | actual set of routes: api for json & html + static pages from disk
type Routes =
- Capture "map.json" JsonFilename :> Capture "params" MapParams :> Get '[JSON] Tiledmap
- -- explicitly capture broken json to return 400 instead of looking for files
- :<|> Capture "map.json" JsonFilename :> CaptureAll "rest" Text :> Get '[JSON] Void
- :<|> Raw
+ "generate" :> Capture "params" MapParams :>
+ (Capture "map.json" JsonFilename :> Get '[JSON] Tiledmap
+ -- explicitly capture broken json to return 400 instead of looking for files
+ :<|> Capture "map.json" JsonFilename :> CaptureAll "rest" Text :> Get '[JSON] Void
+ :<|> Raw)
@@ -90,8 +91,8 @@ mkMap :: Config True -> Tiledmap -> MapParams -> ([SubstitutionError], Tiledmap)
mkMap _config basemap params =
substitute basemap (substs params)
-mapHandler :: Config True -> JsonFilename -> MapParams -> Handler Tiledmap
-mapHandler config (JsonFilename mapname) params =
+mapHandler :: MapParams -> Config True -> JsonFilename -> Handler Tiledmap
+mapHandler params config (JsonFilename mapname) =
case M.lookup mapname (snd $ view template config) of
Just basemap -> runStdoutLoggingT $
logWarnN (pretty errors) >> pure tiledmap
@@ -103,7 +104,8 @@ mapHandler config (JsonFilename mapname) params =
-- | Complete set of routes: API + HTML sites
server :: Config True -> Server Routes
-server config = mapHandler config
+server config params =
+ mapHandler params config
:<|> (\_ _ -> throwError err400)
:<|> serveDirectoryWebApp (fst . view template $ config)