This module parallels elm/http's Http
module.
Pull requests are welcome to add any functions that are missing.
The functions here produce SimulatedEffect
s instead of Cmd
s, which are meant to be used
to help you implement the function to provide when using ProgramTest.withSimulatedEffects
.
get : { url : String, expect : Expect msg } -> ProgramTest.SimulatedEffect msg
Create a GET
request.
post : { url : String, body : Body, expect : Expect msg } -> ProgramTest.SimulatedEffect msg
Create a POST
request.
request : { method : String, headers : List Header, url : String, body : Body, expect : Expect msg, timeout : Maybe Basics.Float, tracker : Maybe String } -> ProgramTest.SimulatedEffect msg
Create a custom request.
( String, String )
An HTTP header for configuring requests.
header : String -> String -> Header
Create a Header
.
Represents the body of a Request
.
emptyBody : Body
Create an empty body for your Request
.
stringBody : String -> String -> Body
Put some string in the body of your Request
.
jsonBody : Json.Encode.Value -> Body
Put some JSON value in the body of your Request
. This will automatically
add the Content-Type: application/json
header.
Logic for interpreting a response body.
expectString : (Result Http.Error String -> msg) -> Expect msg
Expect the response body to be a String
.
expectJson : (Result Http.Error a -> msg) -> Json.Decode.Decoder a -> Expect msg
Expect the response body to be JSON.
expectWhatever : (Result Error () -> msg) -> Expect msg
Expect the response body to be whatever.
Http.Error
expectStringResponse : (Result x a -> msg) -> (Response String -> Result x a) -> Expect msg
Expect a Response with a String body.
Http.Response body
task : { method : String, headers : List Header, url : String, body : Body, resolver : Resolver x a, timeout : Maybe Basics.Float } -> ProgramTest.SimulatedTask x a
Just like request
, but it creates a Task
.
Describes how to resolve an HTTP task.
stringResolver : (Response String -> Result x a) -> Resolver x a
Turn a response with a String
body into a result.