feat: Add explicit headers-only POST request using Prefer header
Allows using header "Prefer=headers-only" explicitly to get a response with only a Location header. BREAKING CHANGE: Change default for POST request from headers-only to minimal Resolves #1656
This commit is contained in:
@@ -334,11 +334,10 @@ userApiRequest confSchemas rootSpec dbStructure req reqBody
|
||||
split :: BS.ByteString -> [Text]
|
||||
split = map T.strip . T.split (==',') . toS
|
||||
representation
|
||||
| hasPrefer (show Full) = Full
|
||||
| hasPrefer (show None) = None
|
||||
| otherwise = if action == ActionCreate
|
||||
then HeadersOnly -- Assume the user wants the Location header(for POST) by default
|
||||
else None
|
||||
| hasPrefer (show Full) = Full
|
||||
| hasPrefer (show None) = None
|
||||
| hasPrefer (show HeadersOnly) = HeadersOnly
|
||||
| otherwise = None
|
||||
auth = fromMaybe "" $ lookupHeader hAuthorization
|
||||
tokenStr = case T.split (== ' ') (toS auth) of
|
||||
("Bearer" : t : _) -> t
|
||||
|
||||
@@ -22,7 +22,7 @@ data PreferRepresentation
|
||||
instance Show PreferRepresentation where
|
||||
show Full = "return=representation"
|
||||
show None = "return=minimal"
|
||||
show HeadersOnly = mempty
|
||||
show HeadersOnly = "return=headers-only"
|
||||
|
||||
data PreferParameters
|
||||
= SingleObject -- ^ Pass all parameters as a single json object to a stored procedure
|
||||
|
||||
Reference in New Issue
Block a user