From 0be5f5299feede5f2cdae9e804a345ef860ea8d7 Mon Sep 17 00:00:00 2001 From: Jacky Hu Date: Thu, 16 Jun 2016 08:25:34 +0800 Subject: [PATCH] Reponse with the correct header for openapi --- src/PostgREST/App.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PostgREST/App.hs b/src/PostgREST/App.hs index e3088b368..25c6f090f 100644 --- a/src/PostgREST/App.hs +++ b/src/PostgREST/App.hs @@ -208,8 +208,9 @@ app dbStructure conf apiRequest = host = configHost conf port = toInteger $ configPort conf encodeFn = if contentType == OpenAPI then encodeApi . toTableInfo else encode + header = if contentType == OpenAPI then openapiH else jsonH body <- encodeFn <$> H.query schema accessibleTables - return $ responseLBS status200 [jsonH] $ cs body + return $ responseLBS status200 [header] $ cs body (ActionInappropriate, _, _) -> return $ responseLBS status405 [] "" @@ -286,6 +287,9 @@ contentRangeH frm to total = jsonH :: Header jsonH = (hContentType, "application/json; charset=utf-8") +openapiH :: Header +openapiH = (hContentType, "application/openapi+json; charset=utf-8") + formatRelationError :: Text -> Text formatRelationError = formatGeneralError "could not find foreign keys between these entities"