From 733b2cc05bb80ed6572e77990bdf0e7b09cf0100 Mon Sep 17 00:00:00 2001 From: Jacky Hu Date: Thu, 16 Jun 2016 08:10:02 +0800 Subject: [PATCH] Move around encodeFn and realted helpers --- src/PostgREST/App.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/PostgREST/App.hs b/src/PostgREST/App.hs index ca3ea19c7..e3088b368 100644 --- a/src/PostgREST/App.hs +++ b/src/PostgREST/App.hs @@ -204,9 +204,11 @@ app dbStructure conf apiRequest = else return notFound (ActionRead, TargetRoot, Nothing) -> do - body <- if contentType == OpenAPI - then (encodeApi . toTableInfo) <$> H.query schema accessibleTables - else encode <$> H.query schema accessibleTables + let encodeApi ti = encodeOpenAPI ti host port + host = configHost conf + 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 (ActionInappropriate, _, _) -> return $ responseLBS status405 [] "" @@ -228,9 +230,6 @@ app dbStructure conf apiRequest = pkeys = map pkName $ filter (filterPk tSchema tTable) allPrKeys in (t, cols, pkeys)) - encodeApi ti = encodeOpenAPI ti host port - host = configHost conf - port = toInteger $ configPort conf notFound = responseLBS status404 [] "" filterPk sc table pk = sc == (tableSchema . pkTable) pk && table == (tableName . pkTable) pk filterCol :: Schema -> TableName -> Column -> Bool