bcardiff/elm-rad/1.0.0

Rad.Http

HTTP effect library for elm-rad. Core Rad has no HTTP dependency; this module owns elm/http entirely.

Handler

type alias Handler =
{ httpGet : String -> Task RequestError String
, httpPost : String -> Value -> Task RequestError String
}

A handler abstracts over how HTTP requests are actually made, so tests can inject mock responses without touching elm/http.

prodHandler : Handler

The production handler — delegates to elm/http.

Errors

= Timeout
| NetworkError
| BadStatus Int
| BadBody String

Errors surfaced by Rad.Http request builders.

A codec for RequestError. Useful as a default error codec when wrapping HTTP results in Remote err a.

Requests

httpGet : Handler -> String -> Decoder a -> Request RequestError a

Build a GET request. The decoder is applied to the response body.

httpPost : Handler -> String -> Value -> Decoder a -> Request RequestError a

Build a POST request. The body is sent as JSON; the decoder is applied to the response.