list collections

This commit is contained in:
Alexander Foremny
2024-06-06 22:52:33 +02:00
parent b1a4822d59
commit 3add980b73
3 changed files with 32 additions and 12 deletions

View File

@@ -221,6 +221,11 @@ main = do
respond $
W.responseLBS W.status200 [] $
J.encode (last repo.commits).schemaVersion
Right ListCollections -> do
repo <- atomically (readTMVar repoT)
respond $
W.responseLBS W.status200 [] $
J.encode (map (.path) (last repo.commits).collections)
(traceShowId -> !_) ->
respond $ W.responseLBS W.status200 [] "not implemented"
@@ -228,13 +233,15 @@ data Route
= SchemaJson String
| Query
| SchemaVersion
| ListCollections
deriving (Show)
routeP :: P.Parser Route
routeP =
( P.choice
[ SchemaJson <$> (P.string "/" *> P.manyTill P.anyChar (P.string ".schema.json")),
[ pure ListCollections <* P.string "/collections",
pure SchemaVersion <* P.string "/schemaVersion",
SchemaJson <$> (P.string "/" *> P.manyTill P.anyChar (P.string ".schema.json")),
pure Query <* P.string "/"
]
)