aboutsummaryrefslogtreecommitdiffstats
path: root/backend/app/Route.hs
blob: 61fa699fdef421f7e4f7f21d503cba2ccfdbe682 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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