aboutsummaryrefslogtreecommitdiffstats
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/backend.cabal1
-rw-r--r--backend/lib/ACMS/API/REST/Collection.hs8
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