forked from loafle/openapi-generator-original
Add sendWithCustomExpect function to Api.mustache (#13773)
to allow more fine grained error handling.
This commit is contained in:
parent
458ea56896
commit
009bf4c0a3
@ -3,6 +3,7 @@ module Api exposing
|
|||||||
, request
|
, request
|
||||||
, send
|
, send
|
||||||
, sendWithCustomError
|
, sendWithCustomError
|
||||||
|
, sendWithCustomExpect
|
||||||
, task
|
, task
|
||||||
, map
|
, map
|
||||||
, withBasePath
|
, withBasePath
|
||||||
@ -55,13 +56,18 @@ send toMsg req =
|
|||||||
|
|
||||||
|
|
||||||
sendWithCustomError : (Http.Error -> e) -> (Result e a -> msg) -> Request a -> Cmd msg
|
sendWithCustomError : (Http.Error -> e) -> (Result e a -> msg) -> Request a -> Cmd msg
|
||||||
sendWithCustomError mapError toMsg (Request req) =
|
sendWithCustomError mapError toMsg req =
|
||||||
|
sendWithCustomExpect (expectJson mapError toMsg) req
|
||||||
|
|
||||||
|
|
||||||
|
sendWithCustomExpect : (Json.Decode.Decoder a -> Http.Expect msg) -> Request a -> Cmd msg
|
||||||
|
sendWithCustomExpect expect (Request req) =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = req.method
|
{ method = req.method
|
||||||
, headers = req.headers
|
, headers = req.headers
|
||||||
, url = Url.Builder.crossOrigin req.basePath req.pathParams req.queryParams
|
, url = Url.Builder.crossOrigin req.basePath req.pathParams req.queryParams
|
||||||
, body = req.body
|
, body = req.body
|
||||||
, expect = expectJson mapError toMsg req.decoder
|
, expect = expect req.decoder
|
||||||
, timeout = req.timeout
|
, timeout = req.timeout
|
||||||
, tracker = req.tracker
|
, tracker = req.tracker
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ module Api exposing
|
|||||||
, request
|
, request
|
||||||
, send
|
, send
|
||||||
, sendWithCustomError
|
, sendWithCustomError
|
||||||
|
, sendWithCustomExpect
|
||||||
, task
|
, task
|
||||||
, map
|
, map
|
||||||
, withBasePath
|
, withBasePath
|
||||||
@ -55,13 +56,18 @@ send toMsg req =
|
|||||||
|
|
||||||
|
|
||||||
sendWithCustomError : (Http.Error -> e) -> (Result e a -> msg) -> Request a -> Cmd msg
|
sendWithCustomError : (Http.Error -> e) -> (Result e a -> msg) -> Request a -> Cmd msg
|
||||||
sendWithCustomError mapError toMsg (Request req) =
|
sendWithCustomError mapError toMsg req =
|
||||||
|
sendWithCustomExpect (expectJson mapError toMsg) req
|
||||||
|
|
||||||
|
|
||||||
|
sendWithCustomExpect : (Json.Decode.Decoder a -> Http.Expect msg) -> Request a -> Cmd msg
|
||||||
|
sendWithCustomExpect expect (Request req) =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = req.method
|
{ method = req.method
|
||||||
, headers = req.headers
|
, headers = req.headers
|
||||||
, url = Url.Builder.crossOrigin req.basePath req.pathParams req.queryParams
|
, url = Url.Builder.crossOrigin req.basePath req.pathParams req.queryParams
|
||||||
, body = req.body
|
, body = req.body
|
||||||
, expect = expectJson mapError toMsg req.decoder
|
, expect = expect req.decoder
|
||||||
, timeout = req.timeout
|
, timeout = req.timeout
|
||||||
, tracker = req.tracker
|
, tracker = req.tracker
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user