From 1c202cf81719da47652247d0f4f2717226a804ae Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 11 May 2023 11:59:57 -0500 Subject: [PATCH] Add `getmainlang` endpoint --- src/ZGoBackend.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ZGoBackend.hs b/src/ZGoBackend.hs index e1e6749..399036e 100644 --- a/src/ZGoBackend.hs +++ b/src/ZGoBackend.hs @@ -849,7 +849,8 @@ routes pipe config = do user <- liftAndCatchIO $ run (findUser sess) case user of Nothing -> status noContent204 - Just u -> status ok200 + Just u -> do + status ok200 --Get user associated with session get "/api/user" $ do sess <- param "session" @@ -1140,6 +1141,14 @@ routes pipe config = do liftAndCatchIO $ run (deleteOrder oId) status ok200 -- Get language for component + get "/getmainlang" $ do + lang <- param "lang" + txtPack' <- liftAndCatchIO $ run (findLangComponent lang "main") + case cast' . Doc =<< txtPack' of + Nothing -> status noContent204 + Just textPack -> do + status ok200 + Web.Scotty.json $ toJSON (textPack :: LangComponent) get "/getloginlang" $ do lang <- param "lang" txtPack' <- liftAndCatchIO $ run (findLangComponent lang "login")