2020-03-04 19:17:06 +03:00
|
|
|
module PagesHttp exposing (..)
|
|
|
|
|
2021-04-02 23:59:07 +03:00
|
|
|
import Http exposing (Response(..))
|
2020-03-04 19:17:06 +03:00
|
|
|
import Pages.Http exposing (..)
|
2021-04-03 07:43:57 +03:00
|
|
|
import SimulatedEffect.Http
|
2020-03-04 19:17:06 +03:00
|
|
|
|
|
|
|
|
2021-04-03 07:43:57 +03:00
|
|
|
expectString : (Result Error String -> msg) -> SimulatedEffect.Http.Expect msg
|
2020-03-04 19:17:06 +03:00
|
|
|
expectString toMsg =
|
2021-04-03 07:43:57 +03:00
|
|
|
SimulatedEffect.Http.expectStringResponse toMsg <|
|
2020-03-04 19:17:06 +03:00
|
|
|
\response ->
|
|
|
|
case response of
|
|
|
|
BadUrl_ url ->
|
|
|
|
Err (BadUrl url)
|
|
|
|
|
|
|
|
Timeout_ ->
|
|
|
|
Err Timeout
|
|
|
|
|
|
|
|
NetworkError_ ->
|
|
|
|
Err NetworkError
|
|
|
|
|
|
|
|
BadStatus_ metadata body ->
|
|
|
|
Err (BadStatus metadata body)
|
|
|
|
|
2021-04-03 00:44:40 +03:00
|
|
|
GoodStatus_ _ body ->
|
2020-03-04 19:17:06 +03:00
|
|
|
Ok body
|