sixsq.slipstream.client.api.utils.http-sync

Simple synchronous wrapper around an HTTP library to produce consistent CRUD interface.

The CRUD actions accept and produce Ring-style requests/responses.

Examples of the request/response.

GET using Basic authn
req := {:accept :xml
        :basic-auth ["user" "password"]}
resp := {:status 200
         :body "<Hello :)>"
         :headers {...}}
GET using cookie
req := {:accept :json
        :headers {:cookie cookie}}
resp := {:status 200
         :body "{"Hello": ":)"}"
         :headers {...}}
(:body (get "https://httpbin.org/get"))

On HTTP error, throws ExceptionInfo with :data containing the full response. The response can be obtained with (ex-data ex)

(let [{:keys [status body]}
      (try
        (get "https://httpbin.org/error")
        (catch ExceptionInfo e (ex-data e)))

delete

(delete url & [req])

get

(get url & [req])

post

(post url & [req])

put

(put url & [req])