about summary refs log tree commit diff
path: root/src/API.hs
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-07-31T10·25+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-07-31T10·25+0100
commited557fb6be749b0b06666674e35db4a75655af08 (patch)
tree14e5d5feeba801a782e68c8c18c17adbed4ca6b9 /src/API.hs
parent7d64011cbd6b0d6ce2237de2a3dfcc1f9f81a4c9 (diff)
Support PATCH /trips
Support a top-level PATCH request to trips that permits any admin to update any
trip, and any user to update any of their trips.

I'm using Aeson's (:?) combinator to support missing fields from the incoming
JSON requests, and then M.fromMaybe to apply these values to any record that
matches the primary key.

See the TODOs that I introduced for some shortcomings.
Diffstat (limited to 'src/API.hs')
-rw-r--r--src/API.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/API.hs b/src/API.hs
index 1bcc47b3a5d6..cc737c16bd72 100644
--- a/src/API.hs
+++ b/src/API.hs
@@ -41,6 +41,10 @@ type API =
            :> Post '[JSON] NoContent
       -- trips: Read
       -- trips: Update
+      :<|> "trips"
+           :> SessionCookie
+           :> ReqBody '[JSON] T.UpdateTripRequest
+           :> Patch '[JSON] NoContent
       -- trips: Delete
       :<|> "trips"
            :> SessionCookie