cov: refactor ApiRequest profile header detection
This commit is contained in:
committed by
Wolfgang Walther
parent
6dd126461e
commit
ba86b479f8
@@ -261,12 +261,17 @@ userApiRequest confSchemas rootSpec dbStructure req reqBody
|
|||||||
profile
|
profile
|
||||||
| length confSchemas <= 1 -- only enable content negotiation by profile when there are multiple schemas specified in the config
|
| length confSchemas <= 1 -- only enable content negotiation by profile when there are multiple schemas specified in the config
|
||||||
= Nothing
|
= Nothing
|
||||||
| action `elem` [ActionCreate, ActionUpdate, ActionSingleUpsert, ActionDelete, ActionInvoke InvPost] -- POST/PATCH/PUT/DELETE don't use the same header as per the spec
|
| otherwise = case action of
|
||||||
= Just $ maybe defaultSchema toS $ lookupHeader "Content-Profile"
|
-- POST/PATCH/PUT/DELETE don't use the same header as per the spec
|
||||||
| action `elem` [ActionRead True, ActionRead False, ActionInvoke InvGet, ActionInvoke InvHead,
|
ActionCreate -> contentProfile
|
||||||
ActionInspect False, ActionInspect True, ActionInfo]
|
ActionUpdate -> contentProfile
|
||||||
= Just $ maybe defaultSchema toS $ lookupHeader "Accept-Profile"
|
ActionSingleUpsert -> contentProfile
|
||||||
| otherwise = Nothing
|
ActionDelete -> contentProfile
|
||||||
|
ActionInvoke InvPost -> contentProfile
|
||||||
|
_ -> acceptProfile
|
||||||
|
where
|
||||||
|
contentProfile = Just $ maybe defaultSchema toS $ lookupHeader "Content-Profile"
|
||||||
|
acceptProfile = Just $ maybe defaultSchema toS $ lookupHeader "Accept-Profile"
|
||||||
schema = fromMaybe defaultSchema profile
|
schema = fromMaybe defaultSchema profile
|
||||||
target =
|
target =
|
||||||
let
|
let
|
||||||
|
|||||||
Reference in New Issue
Block a user