diff options
author | Kierán Meinhardt <kmein@posteo.de> | 2024-10-11 16:53:42 +0200 |
---|---|---|
committer | Kierán Meinhardt <kmein@posteo.de> | 2024-10-11 16:53:42 +0200 |
commit | 08d3a9f867bd92dafa3dc5ccc61254d25993130e (patch) | |
tree | 8a4336f91d55cf82581f80c59b867c16913d338c /backend | |
parent | 4e2bca263be212f5795b845a68cf218ff237d8ab (diff) |
autogenerate collection item IDs
Diffstat (limited to 'backend')
-rw-r--r-- | backend/backend.cabal | 1 | ||||
-rw-r--r-- | backend/lib/ACMS/API/REST/Collection.hs | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/backend/backend.cabal b/backend/backend.cabal index 4909bdf..f92dd46 100644 --- a/backend/backend.cabal +++ b/backend/backend.cabal @@ -41,6 +41,7 @@ library tagged, text, utf8-string, + uuid, wai, warp diff --git a/backend/lib/ACMS/API/REST/Collection.hs b/backend/lib/ACMS/API/REST/Collection.hs index bfbd637..ed0ae9a 100644 --- a/backend/lib/ACMS/API/REST/Collection.hs +++ b/backend/lib/ACMS/API/REST/Collection.hs @@ -8,6 +8,8 @@ import Data.Function ((&)) import Data.Text qualified as T import Network.HTTP.Simple import Text.Printf (printf) +import Data.UUID qualified as U +import Data.UUID.V4 qualified as U type CollectionName = T.Text @@ -37,8 +39,10 @@ update c i o = & httpLBS >>= A.throwDecode . getResponseBody -create :: T.Text -> T.Text -> A.Object -> IO () -create c i o = +create :: T.Text -> A.Object -> IO () +create c o = do + uuid <- U.nextRandom + let i = U.toText uuid <> ".json" "http://localhost:8081" & setRequestMethod "POST" & setRequestBodyLBS |