aboutsummaryrefslogtreecommitdiffstats
path: root/backend/lib/ACMS/API/REST
diff options
context:
space:
mode:
authorLibravatar Kierán Meinhardt <kmein@posteo.de>2024-10-11 16:53:42 +0200
committerLibravatar Kierán Meinhardt <kmein@posteo.de>2024-10-11 16:53:42 +0200
commit08d3a9f867bd92dafa3dc5ccc61254d25993130e (patch)
tree8a4336f91d55cf82581f80c59b867c16913d338c /backend/lib/ACMS/API/REST
parent4e2bca263be212f5795b845a68cf218ff237d8ab (diff)
autogenerate collection item IDs
Diffstat (limited to 'backend/lib/ACMS/API/REST')
-rw-r--r--backend/lib/ACMS/API/REST/Collection.hs8
1 files changed, 6 insertions, 2 deletions
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