mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-24 06:54:03 +03:00
List of routes, not single route, for Api routes.
This commit is contained in:
parent
6e6f09cabc
commit
429a8ae4c1
@ -3,9 +3,10 @@ module ApiHandler exposing (..)
|
||||
import Regex
|
||||
|
||||
|
||||
withRoutes : (constructor -> List String) -> Handler a constructor -> String
|
||||
withRoutes : (constructor -> List (List String)) -> Handler a constructor -> List String
|
||||
withRoutes buildUrls (Handler pattern handler toString constructor) =
|
||||
toString (buildUrls (constructor []))
|
||||
buildUrls (constructor [])
|
||||
|> List.map toString
|
||||
|
||||
|
||||
tryMatch : String -> Handler Response constructor -> Maybe Response
|
||||
|
@ -50,17 +50,15 @@ all =
|
||||
|> literalSegment ".json"
|
||||
|> withRoutes
|
||||
(\constructor ->
|
||||
constructor "100"
|
||||
[ constructor "100" ]
|
||||
-- [
|
||||
--, constructor "101"
|
||||
--]
|
||||
)
|
||||
|> Expect.equal
|
||||
"users/100.json"
|
||||
[ "users/100.json" ]
|
||||
|
||||
-- [
|
||||
--, "users/101.json"
|
||||
--]
|
||||
, describe "multi-part"
|
||||
[ test "multi-level routes" <|
|
||||
\() ->
|
||||
@ -69,25 +67,23 @@ all =
|
||||
(\a ->
|
||||
--constructor "dillonkearns" "elm-pages"
|
||||
--, constructor "101"
|
||||
a "dillonkearns" "elm-pages"
|
||||
[ a "dillonkearns" "elm-pages" ]
|
||||
--, constructor "elm-pages"
|
||||
--]
|
||||
)
|
||||
|> Expect.equal
|
||||
--[
|
||||
"repos/dillonkearns/elm-pages.json"
|
||||
[ "repos/dillonkearns/elm-pages.json" ]
|
||||
|
||||
--, "users/101.json"
|
||||
--]
|
||||
, test "3-level route" <|
|
||||
\() ->
|
||||
threeParts
|
||||
|> withRoutes
|
||||
(\constructor ->
|
||||
constructor "dillonkearns" "elm-pages" "static-files"
|
||||
[ constructor "dillonkearns" "elm-pages" "static-files" ]
|
||||
)
|
||||
|> Expect.equal
|
||||
"repos/dillonkearns/elm-pages/static-files"
|
||||
[ "repos/dillonkearns/elm-pages/static-files" ]
|
||||
|
||||
--, "users/101.json"
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user