Reduces conde duplication assimbling response vody for RPC
This commit is contained in:
@@ -176,9 +176,10 @@ app dbstructure conf reqBody req =
|
|||||||
asJson (callProc qi $ fromMaybe M.empty (decode reqBody))
|
asJson (callProc qi $ fromMaybe M.empty (decode reqBody))
|
||||||
bodyJson :: Maybe (Identity Value) <- H.maybeEx call
|
bodyJson :: Maybe (Identity Value) <- H.maybeEx call
|
||||||
return $ responseLBS status200 [jsonH]
|
return $ responseLBS status200 [jsonH]
|
||||||
(if hasPrefer "return=jwt"
|
(let body = fromMaybe emptyArray $ runIdentity <$> bodyJson in
|
||||||
then ("{\"token\":\"" <> (cs $ tokenJWT jwtSecret $ fromMaybe "[]" $ runIdentity <$> bodyJson) <> "\"}")
|
if hasPrefer "return=jwt"
|
||||||
else (cs $ encode $ fromMaybe emptyArray $ runIdentity <$> bodyJson))
|
then ("{\"token\":\"" <> (cs $ tokenJWT jwtSecret $ body) <> "\"}")
|
||||||
|
else (cs $ encode $ body))
|
||||||
else return $ responseLBS status404 [] ""
|
else return $ responseLBS status404 [] ""
|
||||||
|
|
||||||
-- check that proc exists
|
-- check that proc exists
|
||||||
|
|||||||
Reference in New Issue
Block a user