I’m interested in putting together a small app which would require an HTTP/2 client. There are a lot of references to HTTP/2 servers around, but http-kit and clj-http both appear to provide HTTP/1.1 clients.
If you are running Clojure on Java11 you can use the newly added HttpClient which has full support for HTTP/2. The API is a bit java-ish but works well enough from Clojure.
The entire java.net.http package is pretty powerful and supports everything you’ll ever need to do HTTP requests. Assuming of course you are running Java11 and Clojure.
And horribly verbose though. Yes, you can abstract over this but then you realized you are spending 70% writing interop abstractions instead of business logic. Of course, this is a case where the libs I need are available in Java but not Clojure.
Writing these for clojure beginners to make them aware that the phrase “You can leverage all the Java ecosystem” is not all roses.
Yes, the API doesn’t look like Clojure. For a Java API it is pretty clean and the point is that you do NOT need to abstract it in any way. You can use it directly. The whole point of Clojure is to “embrace the host” and not reinvent everything just because.
Given how “new” Java11 is and how many people are still on Java8 I’d expect a Clojure wrapper for java.net.http at some point. Clojure devs that don’t know Java may be more comfortable with that and that is fine.
HTTP requests can be an incredibly complex subject if you want to do them at scale (thousands, millions, …). Many client libs choose to hide some of the complexities and simplify or compromise in certain situations and that is fine too. Use the right tool for the job …
Was one of the major selling points of Clojure to me. The majority and Clojure beginners also still come from Java (see Q3 in the recent survey results). YMMV.