Prefer NoContent response to Bool

When I first wrote this handler I wasn't aware of the NoContent response
option.
This commit is contained in:
William Carroll 2020-07-28 10:12:25 +01:00
parent 52ac4d79bd
commit 2f73d1db6c
2 changed files with 3 additions and 3 deletions

View file

@ -17,4 +17,4 @@ type API = "user"
:> Get '[JSON] (Maybe T.Account) :> Get '[JSON] (Maybe T.Account)
:<|> "trip" :<|> "trip"
:> ReqBody '[JSON] T.Trip :> ReqBody '[JSON] T.Trip
:> Post '[JSON] Bool :> Post '[JSON] NoContent

View file

@ -42,11 +42,11 @@ server dbFile = userAddH
[x] -> pure (Just x) [x] -> pure (Just x)
_ -> pure Nothing _ -> pure Nothing
createTrip :: T.Trip -> IO Bool createTrip :: T.Trip -> IO NoContent
createTrip trip = withConnection dbFile $ \conn -> do createTrip trip = withConnection dbFile $ \conn -> do
execute conn "INSERT INTO Trips (username,destination,startDate,endDate,comment) VALUES (?,?,?,?,?)" execute conn "INSERT INTO Trips (username,destination,startDate,endDate,comment) VALUES (?,?,?,?,?)"
(trip & T.tripFields) (trip & T.tripFields)
pure True pure NoContent
mkApp :: FilePath -> IO Application mkApp :: FilePath -> IO Application
mkApp dbFile = do mkApp dbFile = do