From c51fecd3b256fc9918494814da63471523e22fb9 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 10 Apr 2024 17:04:42 +0200 Subject: [PATCH] Fix #52: document :throw option --- API.md | 17 +++++++++-------- CHANGELOG.md | 1 + src/babashka/http_client.clj | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/API.md b/API.md index c0fdcc5..3857449 100644 --- a/API.md +++ b/API.md @@ -180,7 +180,7 @@ Options used to create the (implicit) default client. ``` Convenience wrapper for [`request`](#babashka.http-client/request) with method `:delete` -

Source

+

Source

## `get` ``` clojure @@ -190,7 +190,7 @@ Convenience wrapper for [`request`](#babashka.http-client/request) with method ` ``` Convenience wrapper for [`request`](#babashka.http-client/request) with method `:get` -

Source

+

Source

## `head` ``` clojure @@ -200,7 +200,7 @@ Convenience wrapper for [`request`](#babashka.http-client/request) with method ` ``` Convenience wrapper for [`request`](#babashka.http-client/request) with method `:head` -

Source

+

Source

## `patch` ``` clojure @@ -210,7 +210,7 @@ Convenience wrapper for [`request`](#babashka.http-client/request) with method ` ``` Convenience wrapper for [`request`](#babashka.http-client/request) with method `:patch` -

Source

+

Source

## `post` ``` clojure @@ -220,7 +220,7 @@ Convenience wrapper for [`request`](#babashka.http-client/request) with method ` ``` Convenience wrapper for [`request`](#babashka.http-client/request) with method `:post` -

Source

+

Source

## `put` ``` clojure @@ -230,7 +230,7 @@ Convenience wrapper for [`request`](#babashka.http-client/request) with method ` ``` Convenience wrapper for [`request`](#babashka.http-client/request) with method `:put` -

Source

+

Source

## `request` ``` clojure @@ -256,10 +256,11 @@ Perform request. Returns map with at least `:body`, `:status` * `: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. + * `: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`. -

Source

+

Source

----- # babashka.http-client.interceptors diff --git a/CHANGELOG.md b/CHANGELOG.md index 38fd0da..138f687 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Babashka [http-client](https://github.com/babashka/http-client): HTTP client for ## Unreleased - [#49](https://github.com/babashka/http-client/issues/49): add `::oauth-token` interceptor +- [#52](https://github.com/babashka/http-client/issues/52): document `:throw` option ## 0.4.16 (2024-02-10) diff --git a/src/babashka/http_client.clj b/src/babashka/http_client.clj index 21705e6..e714283 100644 --- a/src/babashka/http_client.clj +++ b/src/babashka/http_client.clj @@ -116,7 +116,8 @@ * `: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. + * `: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`. " [opts]