diff --git a/src/PostgREST/ApiRequest.hs b/src/PostgREST/ApiRequest.hs index 73043cb70..cd14d332d 100644 --- a/src/PostgREST/ApiRequest.hs +++ b/src/PostgREST/ApiRequest.hs @@ -48,7 +48,6 @@ data Action = ActionCreate | ActionRead | ActionUpdate | ActionDelete | ActionInfo | ActionInvoke | ActionInspect - | ActionInappropriate deriving Eq -- | The target db object of a user action data Target = TargetIdent QualifiedIdentifier @@ -181,7 +180,7 @@ userApiRequest schema req reqBody "PATCH" -> ActionUpdate "DELETE" -> ActionDelete "OPTIONS" -> ActionInfo - _ -> ActionInappropriate + _ -> ActionInspect target = case path of [] -> TargetRoot [table] -> TargetIdent diff --git a/src/PostgREST/App.hs b/src/PostgREST/App.hs index a2a89dab3..345d97f9a 100644 --- a/src/PostgREST/App.hs +++ b/src/PostgREST/App.hs @@ -95,8 +95,8 @@ postgrest conf refDbStructure pool getTime = (HT.run handleReq HT.ReadCommitted txMode) respond resp where - respondToError error = - case error of + respondToError err = + case err of ErrorActionInappropriate -> errResponse status405 "Bad Request" ErrorInvalidBody errorMessage -> errResponse status400 $ toS errorMessage @@ -286,10 +286,7 @@ app dbStructure conf apiRequest = else response responseContentTypeOrError :: [ContentType] -> Action -> Either Response ContentType -responseContentTypeOrError accepts action = - case action of - ActionInappropriate -> Left $ errResponse status405 "Unsupported HTTP verb" - _ -> serves contentTypesForRequest accepts +responseContentTypeOrError accepts action = serves contentTypesForRequest accepts where contentTypesForRequest = case action of @@ -300,7 +297,6 @@ responseContentTypeOrError accepts action = ActionInvoke -> [CTApplicationJSON] ActionInspect -> [CTOpenAPI] ActionInfo -> [CTTextCSV] - ActionInappropriate -> [] serves sProduces cAccepts = case mutuallyAgreeable sProduces cAccepts of Nothing -> do