@@ -23,11 +23,18 @@ toc::[]
23
23
24
24
== Installation
25
25
26
- `clj-http-lite` is available as a Maven artifact from https://clojars.org/org.clj-commons/clj-http-lite[Clojars]:
26
+ Clojure cli users, add the following under `:deps` in your `deps.edn` file. +
27
+ Babashka users, add the following under `:deps` in your `bb.edn` file:
28
+ [source,clojure,subs="attributes+"]
29
+ ----
30
+ org.clj-commons/clj-http-lite {:mnv/version "{lib-version}"}
31
+ ----
32
+
33
+ Lein users, add the following into the `:dependencies` vector in your `project.clj` file:
27
34
28
35
[source,clojure,subs="attributes+"]
29
36
----
30
- [org.clj-commons/clj-http-lite "{lib-version}"]
37
+ [org.clj-commons/clj-http-lite "{lib-version}"]
31
38
----
32
39
33
40
== Differences from clj-http
@@ -39,7 +46,7 @@ toc::[]
39
46
* No multipart form uploads
40
47
* No persistent connection support
41
48
* Fewer options
42
- * namespace rename clj-http.* -> clj-http.lite.*
49
+ * namespace rename ` clj-http.*` -> ` clj-http.lite.*`
43
50
44
51
Like its namesake, clj-http-lite is light and simple, but ping us if there is some clj-http feature you’d like to see in clj-http-lite.
45
52
We can discuss.
@@ -54,7 +61,7 @@ We can discuss.
54
61
== Usage
55
62
56
63
=== General
57
- The main HTTP client functionality is provided by the `clj-http.lite.client` namespace:
64
+ HTTP client functionality is provided by the `clj-http.lite.client` namespace:
58
65
59
66
[source,clojure]
60
67
----
@@ -75,7 +82,7 @@ They all return Ring-style response maps:
75
82
:body "<!doctype html>..."}
76
83
----
77
84
78
- TIP: We encourage you to try out these examples in your REPL, `httpbin.org` is a free HTTP test playground and used in many examples.
85
+ TIP: We encourage you to try out these examples in your REPL, `httpbin.org` is a free HTTP test playground and used in many of our examples.
79
86
80
87
[source,clojure]
81
88
----
@@ -226,7 +233,8 @@ A more general `request` function is also available, which is useful as a primit
226
233
227
234
=== Exceptions
228
235
229
- The client will throw exceptions on, exceptional HTTP status codes. Clj-http-lite throws an `ex-info` with the response as `ex-data`.
236
+ When a server returns an exceptional HTTP status code, by default, clj-http-lite throws an `ex-info` exception.
237
+ The response is included as `ex-data`.
230
238
231
239
[source,clojure]
232
240
----
@@ -240,14 +248,15 @@ The client will throw exceptions on, exceptional HTTP status codes. Clj-http-lit
240
248
;; => (:headers :status :body)
241
249
----
242
250
243
- You can suppress HTTP status exceptions and handle them yourself:
251
+ You can suppress HTTP status exceptions and handle them yourself via the `:throw-exceptions` option :
244
252
245
253
[source,clojure]
246
254
----
247
255
(client/get "https://httpbin.org/404" {:throw-exceptions false})
248
256
----
249
257
250
- Or ignore an unknown host (methods return `nil' if this is set to true and the host does not exist:
258
+ You can choose to ignore an unknown host via `:ingore-unknown-host?` option.
259
+ When enabled, requests return `nil` if the host is not found.
251
260
252
261
[source,clojure]
253
262
----
@@ -393,7 +402,7 @@ $ bb lint
393
402
394
403
=== Release
395
404
396
- To release a new version, run `bb publish` which will push a new tag.
405
+ To release a new version, run `bb publish` which will push a new tag.
397
406
CI will take care of the rest.
398
407
399
408
== License
0 commit comments