mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-27 11:05:46 +03:00
Remove redundant implementation.
This commit is contained in:
parent
094e905dd5
commit
3976ec436a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user