mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 21:02:33 +03:00
Use local artificial error API to avoid rate limit.
This commit is contained in:
parent
c24d93d705
commit
ad3d68cc9b
@ -56,9 +56,26 @@ routes getStaticRoutes htmlToString =
|
||||
, requestPrinter
|
||||
, xmlDecoder
|
||||
, multipleContentTypes
|
||||
, errorRoute
|
||||
]
|
||||
|
||||
|
||||
errorRoute : ApiRoute ApiRoute.Response
|
||||
errorRoute =
|
||||
ApiRoute.succeed
|
||||
(\errorCode ->
|
||||
Request.succeed
|
||||
(Response.plainText ("Here is the error code you requested (" ++ errorCode ++ ")")
|
||||
|> Response.withStatusCode (String.toInt errorCode |> Maybe.withDefault 500)
|
||||
|> BackendTask.succeed
|
||||
)
|
||||
)
|
||||
|> ApiRoute.literal "error-code"
|
||||
|> ApiRoute.slash
|
||||
|> ApiRoute.capture
|
||||
|> ApiRoute.serverRender
|
||||
|
||||
|
||||
xmlDecoder : ApiRoute ApiRoute.Response
|
||||
xmlDecoder =
|
||||
let
|
||||
|
@ -10,7 +10,7 @@ import Test exposing (Test)
|
||||
|
||||
all : BackendTask FatalError Test
|
||||
all =
|
||||
[ BackendTask.Http.get "http://httpstat.us/500" (BackendTask.Http.expectWhatever ())
|
||||
[ BackendTask.Http.get "http://localhost:1234/error-code/500" (BackendTask.Http.expectWhatever ())
|
||||
|> BackendTask.mapError .recoverable
|
||||
|> test "http 500 error"
|
||||
(\result ->
|
||||
@ -27,7 +27,7 @@ all =
|
||||
Ok () ->
|
||||
Expect.fail "Expected HTTP error, got Ok"
|
||||
)
|
||||
, BackendTask.Http.get "http://httpstat.us/404" (BackendTask.Http.expectWhatever ())
|
||||
, BackendTask.Http.get "http://localhost:1234/error-code/404" (BackendTask.Http.expectWhatever ())
|
||||
|> BackendTask.mapError .recoverable
|
||||
|> test "http 404 error"
|
||||
(\result ->
|
||||
|
Loading…
Reference in New Issue
Block a user