diff options
Diffstat (limited to 'src/server/Json.hs')
-rw-r--r-- | src/server/Json.hs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/server/Json.hs b/src/server/Json.hs index 51287ed..bd5ac3e 100644 --- a/src/server/Json.hs +++ b/src/server/Json.hs @@ -1,12 +1,22 @@ +{-# LANGUAGE OverloadedStrings #-} + module Json - ( jsonObject + ( jsonError + , jsonObject ) where -import Web.Scotty (json, ActionM) +import Web.Scotty + +import Network.HTTP.Types.Status (badRequest400) import qualified Data.Aeson.Types as Json import qualified Data.HashMap.Strict as M import Data.Text (Text) +jsonError :: Text -> ActionM () +jsonError msg = do + status badRequest400 + jsonObject [("error", Json.String msg)] + jsonObject :: [(Text, Json.Value)] -> ActionM () jsonObject = json . Json.Object . M.fromList |