Skip to content
Snippets Groups Projects
Commit 833186af authored by stuebinm's avatar stuebinm
Browse files

cwality-maps: change routes

otherwise workadventure & the deployment got confused
parent 72760b0f
No related branches found
No related tags found
No related merge requests found
...@@ -78,10 +78,11 @@ instance FromHttpApiData MapParams where ...@@ -78,10 +78,11 @@ instance FromHttpApiData MapParams where
-- | actual set of routes: api for json & html + static pages from disk -- | actual set of routes: api for json & html + static pages from disk
type Routes = type Routes =
Capture "map.json" JsonFilename :> Capture "params" MapParams :> Get '[JSON] Tiledmap "generate" :> Capture "params" MapParams :>
-- explicitly capture broken json to return 400 instead of looking for files (Capture "map.json" JsonFilename :> Get '[JSON] Tiledmap
:<|> Capture "map.json" JsonFilename :> CaptureAll "rest" Text :> Get '[JSON] Void -- explicitly capture broken json to return 400 instead of looking for files
:<|> Raw :<|> Capture "map.json" JsonFilename :> CaptureAll "rest" Text :> Get '[JSON] Void
:<|> Raw)
...@@ -90,8 +91,8 @@ mkMap :: Config True -> Tiledmap -> MapParams -> ([SubstitutionError], Tiledmap) ...@@ -90,8 +91,8 @@ mkMap :: Config True -> Tiledmap -> MapParams -> ([SubstitutionError], Tiledmap)
mkMap _config basemap params = mkMap _config basemap params =
substitute basemap (substs params) substitute basemap (substs params)
mapHandler :: Config True -> JsonFilename -> MapParams -> Handler Tiledmap mapHandler :: MapParams -> Config True -> JsonFilename -> Handler Tiledmap
mapHandler config (JsonFilename mapname) params = mapHandler params config (JsonFilename mapname) =
case M.lookup mapname (snd $ view template config) of case M.lookup mapname (snd $ view template config) of
Just basemap -> runStdoutLoggingT $ Just basemap -> runStdoutLoggingT $
logWarnN (pretty errors) >> pure tiledmap logWarnN (pretty errors) >> pure tiledmap
...@@ -103,7 +104,8 @@ mapHandler config (JsonFilename mapname) params = ...@@ -103,7 +104,8 @@ mapHandler config (JsonFilename mapname) params =
-- | Complete set of routes: API + HTML sites -- | Complete set of routes: API + HTML sites
server :: Config True -> Server Routes server :: Config True -> Server Routes
server config = mapHandler config server config params =
mapHandler params config
:<|> (\_ _ -> throwError err400) :<|> (\_ _ -> throwError err400)
:<|> serveDirectoryWebApp (fst . view template $ config) :<|> serveDirectoryWebApp (fst . view template $ config)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment