This repository was archived by the owner on May 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
This repository was archived by the owner on May 9, 2018. It is now read-only.
High level requests for verbs other than POST/GET #32
Copy link
Copy link
Open
Description
Currently, there are only two "high-level" HTTP functions, get and post. It seems to me that PUT and DELETE would also be very useful. What do you think?
Parenthetically, the Consul HTTP API supports GET, PUT, and DELETE.
I'm currently using the following implementation of putString, delString:
{-| Mirror the getString API, but for PUT requests.
-}
httpPutString : String -> String -> Task Error String
httpPutString =
wrapHttpApi "PUT"
{-| Mirror the getString API, but for DELETE requests.
-}
httpDelString : String -> Task Error String
httpDelString =
flip (wrapHttpApi "DELETE") ""
{-| Create a high-level API for some HTTP verb other than GET/POST
-}
wrapHttpApi : String -> String -> String -> Task Error String
wrapHttpApi verb url body =
let
request =
{ verb = verb, headers = [], url = url, body = Http.string body }
in
Task.mapError promoteError (Http.send Http.defaultSettings request)
`andThen` handleResponse Task.succeed with handleResponse and promoteError copied directly from this module's source.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels