Move around encodeFn and realted helpers
This commit is contained in:
@@ -204,9 +204,11 @@ app dbStructure conf apiRequest =
|
|||||||
else return notFound
|
else return notFound
|
||||||
|
|
||||||
(ActionRead, TargetRoot, Nothing) -> do
|
(ActionRead, TargetRoot, Nothing) -> do
|
||||||
body <- if contentType == OpenAPI
|
let encodeApi ti = encodeOpenAPI ti host port
|
||||||
then (encodeApi . toTableInfo) <$> H.query schema accessibleTables
|
host = configHost conf
|
||||||
else encode <$> H.query schema accessibleTables
|
port = toInteger $ configPort conf
|
||||||
|
encodeFn = if contentType == OpenAPI then encodeApi . toTableInfo else encode
|
||||||
|
body <- encodeFn <$> H.query schema accessibleTables
|
||||||
return $ responseLBS status200 [jsonH] $ cs body
|
return $ responseLBS status200 [jsonH] $ cs body
|
||||||
|
|
||||||
(ActionInappropriate, _, _) -> return $ responseLBS status405 [] ""
|
(ActionInappropriate, _, _) -> return $ responseLBS status405 [] ""
|
||||||
@@ -228,9 +230,6 @@ app dbStructure conf apiRequest =
|
|||||||
pkeys = map pkName $ filter (filterPk tSchema tTable) allPrKeys
|
pkeys = map pkName $ filter (filterPk tSchema tTable) allPrKeys
|
||||||
in
|
in
|
||||||
(t, cols, pkeys))
|
(t, cols, pkeys))
|
||||||
encodeApi ti = encodeOpenAPI ti host port
|
|
||||||
host = configHost conf
|
|
||||||
port = toInteger $ configPort conf
|
|
||||||
notFound = responseLBS status404 [] ""
|
notFound = responseLBS status404 [] ""
|
||||||
filterPk sc table pk = sc == (tableSchema . pkTable) pk && table == (tableName . pkTable) pk
|
filterPk sc table pk = sc == (tableSchema . pkTable) pk && table == (tableName . pkTable) pk
|
||||||
filterCol :: Schema -> TableName -> Column -> Bool
|
filterCol :: Schema -> TableName -> Column -> Bool
|
||||||
|
|||||||
Reference in New Issue
Block a user