about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-07-28T09·12+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-07-28T09·12+0100
commit2f73d1db6c2ec107a9af1572f023b6c95133229c (patch)
tree0368e62486dc23b0fd333a7c8ef2e333821b4375 /src
parent52ac4d79bda2c5f5cc2ff636e79b4bf3b5979868 (diff)
Prefer NoContent response to Bool
When I first wrote this handler I wasn't aware of the NoContent response
option.
Diffstat (limited to 'src')
-rw-r--r--src/API.hs2
-rw-r--r--src/App.hs4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/API.hs b/src/API.hs
index f858e6d7ab53..ef185e246cd0 100644
--- a/src/API.hs
+++ b/src/API.hs
@@ -17,4 +17,4 @@ type API = "user"
            :> Get  '[JSON] (Maybe T.Account)
       :<|> "trip"
            :> ReqBody '[JSON] T.Trip
-           :> Post '[JSON] Bool
+           :> Post '[JSON] NoContent
diff --git a/src/App.hs b/src/App.hs
index 20d99e385ad2..d244c9b56740 100644
--- a/src/App.hs
+++ b/src/App.hs
@@ -42,11 +42,11 @@ server dbFile = userAddH
         [x] -> pure (Just x)
         _   -> pure Nothing
 
-    createTrip :: T.Trip -> IO Bool
+    createTrip :: T.Trip -> IO NoContent
     createTrip trip = withConnection dbFile $ \conn -> do
       execute conn "INSERT INTO Trips (username,destination,startDate,endDate,comment) VALUES (?,?,?,?,?)"
         (trip & T.tripFields)
-      pure True
+      pure NoContent
 
 mkApp :: FilePath -> IO Application
 mkApp dbFile = do