Skip to main content

request

function

babashka.http-client/request

(request [opts])
Perform request. Returns map with at least `:body`, `:status` Options: * `:uri` - the uri to request (required). May be a string or map of `:scheme` (required), `:host` (required), `:port`, `:path` and `:query` * `:headers` - a map of headers * `:method` - the request method: `:get`, `:post`, `:head`, `:delete`, `:patch` or `:put` * `:interceptors` - custom interceptor chain * `:client` - a client as produced by `client` or a clojure function. If not provided a default client will be used. When providing :client with a a clojure function, it will be called with the Clojure representation of the request which can be useful for testing. * `:query-params` - a map of query params. The values can be a list to send multiple params with the same key. * `:form-params` - a map of form params to send in the request body. * `:body` - a file, inputstream or string to send as the request body. * `:basic-auth` - a sequence of `user` `password` or map with `:user` `:pass` used for basic auth. * `:oauth-token` - a string token used for bearer auth. * `:async` - perform request asynchronously. The response will be a `CompletableFuture` of the response map. * `:async-then` - a function that is called on the async result if successful * `:async-catch` - a function that is called on the async result if exceptional * `:timeout` - request timeout in milliseconds * `:throw` - throw on exceptional status codes, all other than `#{200 201 202 203 204 205 206 207 300 301 302 303 304 307}` * `:version` - the HTTP version: `:http1.1` or `:http2`.

No examples yet. Be the first to add one!