Remove redundant implementation.

This commit is contained in:
Dillon Kearns 2022-02-16 17:08:46 -08:00
parent 094e905dd5
commit 3976ec436a

View File

@ -224,75 +224,7 @@ internalRequest :
-> Expect a
-> DataSource a
internalRequest request_ expect =
case expect of
ExpectJson decoder ->
Request
[ request_ ]
(\rawResponseDict ->
rawResponseDict
|> RequestsAndPending.get (request_ |> HashRequest.hash)
|> (\maybeResponse ->
case maybeResponse of
Just rawResponse ->
Ok rawResponse
Nothing ->
Err (Pages.StaticHttpRequest.MissingHttpResponse (requestToString request_) [ request_ ])
)
|> Result.andThen
(\(RequestsAndPending.Response maybeResponse body) ->
case body of
RequestsAndPending.JsonBody json ->
json
|> Json.Decode.decodeValue decoder
|> Result.mapError
(\error ->
error
|> Json.Decode.errorToString
|> Pages.StaticHttpRequest.DecoderError
)
_ ->
("Unexpected Response type. Expected JSON but was " ++ RequestsAndPending.responseKindString body)
|> Pages.StaticHttpRequest.DecoderError
|> Err
)
|> toResult
)
ExpectString mapStringFn ->
Request
[ request_ ]
(\rawResponseDict ->
rawResponseDict
|> RequestsAndPending.get (request_ |> HashRequest.hash)
|> (\maybeResponse ->
case maybeResponse of
Just rawResponse ->
Ok rawResponse
Nothing ->
Err (Pages.StaticHttpRequest.MissingHttpResponse (requestToString request_) [ request_ ])
)
|> Result.andThen
(\(RequestsAndPending.Response maybeResponse body) ->
case body of
RequestsAndPending.StringBody string ->
string
|> mapStringFn
|> Result.mapError Pages.StaticHttpRequest.DecoderError
_ ->
("Unexpected Response type. Expected String but was " ++ RequestsAndPending.responseKindString body)
|> Pages.StaticHttpRequest.DecoderError
|> Err
)
|> toResult
)
ExpectResponse _ ->
Pages.StaticHttpRequest.DecoderError "Not handled yet TODO"
|> RequestError
request request_ expect
expectToString : Expect a -> String