31 lines
482 B
Elm
31 lines
482 B
Elm
module Route exposing (..)
|
|
|
|
import Url exposing (Url)
|
|
import Url.Parser exposing (..)
|
|
|
|
|
|
type Route
|
|
= NotFound
|
|
| Home
|
|
| Files
|
|
| Status String
|
|
|
|
|
|
parseUrl : Url -> Route
|
|
parseUrl url =
|
|
case parse matchRoute url of
|
|
Just route ->
|
|
route
|
|
|
|
Nothing ->
|
|
NotFound
|
|
|
|
|
|
matchRoute : Parser (Route -> a) a
|
|
matchRoute =
|
|
oneOf
|
|
[ map Home top
|
|
, map Files (s "files")
|
|
, map Status (s "status" </> string)
|
|
]
|