From 0afcaed0764e0007de66f608103364e94b19851d Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Wed, 10 May 2023 14:58:31 -0500 Subject: [PATCH] Add new endpoint for login language --- CHANGELOG.md | 1 + src/ZGoBackend.hs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54f0bf2..f4f81bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `isUserValid` function - New middleware to validated requests come from an existing user +- New endpoint for the language data of the login page ### Changed diff --git a/src/ZGoBackend.hs b/src/ZGoBackend.hs index 156c791..116002a 100644 --- a/src/ZGoBackend.hs +++ b/src/ZGoBackend.hs @@ -1133,6 +1133,14 @@ routes pipe config = do liftAndCatchIO $ run (deleteOrder oId) status ok200 -- Get language for component + get "getloginlang" $ do + lang <- param "lang" + txtPack' <- liftAndCatchIO $ run (findLangComponent lang "login") + case cast' . Doc =<< txtPack' of + Nothing -> status noContent204 + Just textPack -> do + status ok200 + Web.Scotty.json $ toJSON (textPack :: LangComponent) get "/api/getlang" $ do component <- param "component" lang <- param "lang"