Add PATCH handler
This commit is contained in:
+9
-6
@@ -131,6 +131,15 @@ app conn req respond =
|
|||||||
"You must specify all columns in PUT request"
|
"You must specify all columns in PUT request"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
([table], "PATCH") ->
|
||||||
|
handleJsonObj req (\obj -> do
|
||||||
|
let qt = QualifiedTable schema (cs table)
|
||||||
|
_ <- uncurry (execute conn)
|
||||||
|
$ whereT qq
|
||||||
|
$ update qt (map cs $ keys obj) (elems obj)
|
||||||
|
return $ responseLBS status204 [ jsonH ] ""
|
||||||
|
)
|
||||||
|
|
||||||
(_, _) ->
|
(_, _) ->
|
||||||
return $ responseLBS status404 [] ""
|
return $ responseLBS status404 [] ""
|
||||||
|
|
||||||
@@ -221,12 +230,6 @@ instance ToJSON TableOptions where
|
|||||||
-- ] ""
|
-- ] ""
|
||||||
|
|
||||||
|
|
||||||
-- ([table], "PATCH") ->
|
|
||||||
-- jsonBodyAction req (\row -> do
|
|
||||||
-- _ <- update ver table row qq conn
|
|
||||||
-- return $ responseLBS status204 [ jsonContentType ] ""
|
|
||||||
-- )
|
|
||||||
|
|
||||||
-- (_, _) ->
|
-- (_, _) ->
|
||||||
-- return $ responseLBS status404 [] ""
|
-- return $ responseLBS status404 [] ""
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ whereT :: Net.Query -> CompleteQueryT
|
|||||||
whereT params q =
|
whereT params q =
|
||||||
if L.null params
|
if L.null params
|
||||||
then q
|
then q
|
||||||
else q <> conjunction
|
else q <> (" where ",[]) <> conjunction
|
||||||
where
|
where
|
||||||
cols = [ col | col <- params, fst col `notElem` ["order"] ]
|
cols = [ col | col <- params, fst col `notElem` ["order"] ]
|
||||||
conjunction = mconcat $ L.intersperse andq (map wherePred cols)
|
conjunction = mconcat $ L.intersperse andq (map wherePred cols)
|
||||||
|
|||||||
Reference in New Issue
Block a user