I've just started learning Clojure and am struggling with the API changes over the past few years. In particular, in 1.2 there was an http-agent function in contrib which allowed for really simple HTTP requests:
(http-agent "http..." :method "POST" :body "foo=1")
This function was removed and it seems that now you should either use clojure.java.io or a 3rd party solution like http-kit or clj-http.
I'm really surprised as java.io
seems much lower-level and loses the simplicity or http-agent and making http requests seems like something that should be in the core set of libraries (I realise this is very subjective).
What's the rationale for the removal of http-agent? Did it not fit with a core philosophy of Clojure? And what are recommendations for the best library to use for basic HTTP requests?
I cannot make authoritative statements about the reasons why any particular part of old contrib failed to make it into the new contrib, but in general things were moved over when sufficiently many people were interested, including some able and willing to maintain the new libraries. Perhaps in this case there simply wasn't enough interest.
Additionally, it is extremely straightforward to build Clojure projects on top of multiple libraries and it is not clear that the presence of an http client library in the core set of libraries or the contrib would make things any simpler and/or easier for developers than they are now, with excellent options available in the wider ecosystem.
As for particular examples of such excellent options, I'd point you towards clj-http and http.async.client (in alphabetical order; which one is appropriate depends on whether you'd benefit from firing off your requests asynchronously).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With