mi/sina/src/Route.elm

28 lines
640 B
Elm
Raw Normal View History

2020-11-16 16:26:03 +00:00
module Route exposing (Route(..), routeParser)
2020-11-16 02:52:38 +00:00
2020-11-16 16:26:03 +00:00
import Url.Parser exposing ((</>), Parser, map, oneOf, s, string)
2020-11-16 02:52:38 +00:00
type Route
= Index
| Login
2020-11-16 15:10:57 +00:00
| NotFound
2020-11-16 16:26:03 +00:00
| SwitchLog
2020-11-16 02:52:38 +00:00
| SwitchID String
| MakeSwitch
2020-11-16 16:26:03 +00:00
| WebMentionLog
2020-11-16 02:52:38 +00:00
| WebMentionID String
routeParser : Parser (Route -> a) a
routeParser =
oneOf
[ map Index (s "")
, map Login (s "login")
2020-11-16 16:26:03 +00:00
, map SwitchLog (s "switches")
2020-11-16 02:52:38 +00:00
, map SwitchID (s "switches" </> string)
, map MakeSwitch (s "switches" </> s "log")
2020-11-16 16:26:03 +00:00
, map WebMentionLog (s "webmentions")
2020-11-16 02:52:38 +00:00
, map WebMentionID (s "webmentions" </> string)
]