From 8a34cc822c2c508472fe29ab2be1b74ba06e59e6 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Fri, 7 Jun 2024 16:14:52 +0200 Subject: add collections --- backend/app/Route.hs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 backend/app/Route.hs (limited to 'backend/app/Route.hs') diff --git a/backend/app/Route.hs b/backend/app/Route.hs new file mode 100644 index 0000000..61fa699 --- /dev/null +++ b/backend/app/Route.hs @@ -0,0 +1,21 @@ +module Route (Route (..), parser) where + +import Data.Attoparsec.Char8 qualified as P + +data Route + = SchemaJson String + | Query + | SchemaVersion + | Collections + deriving (Show) + +parser :: P.Parser Route +parser = + ( P.choice + [ pure Collections <* P.string "/collections", + pure SchemaVersion <* P.string "/schemaVersion", + SchemaJson <$> (P.string "/" *> P.manyTill P.anyChar (P.string ".schema.json")), + pure Query <* P.string "/" + ] + ) + <* P.endOfInput -- cgit v1.2.3