the-sett/elm-aws-core/6.0.0

NOTE: the latest version is 9.0.0

AWS.Http

Handling of HTTP requests to AWS Services.

Tasks for sending requests to AWS.

send : Service -> Credentials -> Request a -> Task Error a

Signs and sends a Request to a Service.

sendUnsigned : Service -> Request a -> Task Error a

Sends a Request to a Service without signing it.

Build a Request

type Method
= DELETE
| GET
| HEAD
| OPTIONS
| POST
| PUT

HTTP request methods.

type alias Path =
String

Request path.

type alias Request a =
Request a

Holds an unsigned AWS HTTP request.

request : String -> Method -> Path -> Body -> ResponseDecoder a -> Request a

Creates an unsigned HTTP request to an AWS service.

Build the HTTP Body of a Request

type alias Body =
Body

Holds a request body.

type alias MimeType =
String
emptyBody : Body

Create an empty body.

stringBody : MimeType -> String -> Body

Create a body with a custom MIME type and the given string as content.

stringBody "text/html" "<html><body><h1>Hello</h1></body></html>"
jsonBody : Value -> Body

Create a body containing a JSON value.

This will automatically add the Content-Type: application/json header.

Add headers or query parameters to a Request

addHeaders : List ( String, String ) -> Request a -> Request a

Appends headers to an AWS HTTP unsigned request.

See the AWS.KVEncode for encoder functions to build the headers with.

addQuery : List ( String, String ) -> Request a -> Request a

Appends query arguments to an AWS HTTP unsigned request.

See the AWS.KVEncode for encoder functions to build the query parameters with.

Build decoders to interpret the response.

type alias ResponseDecoder a =
ResponseDecoder a

Decoders that interpret responses.

= GoodStatus
| BadStatus

The HTTP response code type according to how Elm.Http classifies responses.

A code from 200 to less than 300 is considered 'Good' and any other code is considered 'Bad'.

(HttpStatus -> Metadata -> String -> Result String a)
-> ResponseDecoder a

A full decoder for the response that can look at the status code, metadata including headers and so on. The body is presented as a String for parsing.

It is possible to report an error as a String when interpreting the response, and this will be mapped onto Http.BadBody when present.

jsonFullDecoder : (HttpStatus -> Metadata -> Decoder a) -> ResponseDecoder a

A full JSON decoder for the response that can look at the status code, metadata including headers and so on. The body is presented as a JSON Value for decoding.

Any decoder error is mapped onto Http.BadBody as a String when present using Decode.errorToString.

stringBodyDecoder : (String -> Result String a) -> ResponseDecoder a

A decoder for the response that uses only the body presented as a String for parsing.

It is possible to report an error as a String when interpreting the response, and this will be mapped onto Http.BadBody when present.

Note that this decoder is only used when the response is Http.GoodStatus_. An Http.BadStatus_ is always mapped to Http.BadStatus without attempting to decode the body. If you need to handle things that Elm HTTP regards as BadStatus_, use one of the 'full' decoders.

jsonBodyDecoder : Decoder a -> ResponseDecoder a

A decoder for the response that uses only the body presented as a JSON Value for decoding.

Any decoder error is mapped onto Http.BadBody as a String when present using Decode.errorToString.

Note that this decoder is only used when the response is Http.GoodStatus_. An Http.BadStatus_ is always mapped to Http.BadStatus without attempting to decode the body. If you need to handle things that Elm HTTP regards as BadStatus_, use one of the 'full' decoders.

constantDecoder : a -> ResponseDecoder a

Not all AWS service produce a response that contains useful information.

The constantDecoder is helpful in those situations and just produces whatever value you give it once AWS has responded.

Note that this decoder is only used when the response is Http.GoodStatus_. An Http.BadStatus_ is always mapped to Http.BadStatus without attempting to decode the body. If you need to handle things that Elm HTTP regards as BadStatus_, use one of the 'full' decoders.