Fork me on GitHub
#clojure
<
2020-10-30
>
timsgardner08:10:53

Hello, I'm wondering if people have recommendations for a straightforward Clojure request library with reasonable async support, along the lines of axios? I'm looking at https://github.com/dakrone/clj-http, I don't know if that's the current state of the art however. Thanks!

flowthing08:10:05

Not familiar with Axios, but you might also want to take a look at https://github.com/gnarroway/hato or https://github.com/schmee/java-http-clj for no-dependencies options (if you’re on Java 11+).

timsgardner08:10:41

Thanks! I'll check those out

borkdude08:10:27

@U3Q8MMREX since httpkit is part of babashka, you can also use it in shell scripts. Btw, I enjoyed the podcast interview on defnpodcast a while ago.

timsgardner08:10:58

it's funny to be getting back into normal JVM clojure, I've just been in the Arcadia pocket universe for years

timsgardner08:10:04

I was trying to scrape the Notion API in python and I got really frustrated with the REPL experience. So here I am

timsgardner08:10:18

Have you used Aleph at all? I was looking at it because I like Zach's libs, it does seem more complicated than http-kit in some ways

borkdude08:10:48

I've mostly used Aleph server, but I've also used the client. It works

dharrigan11:10:53

I use clj-http and it supports async operations. Works great.

mpenet11:10:02

starting to use jdk11 client more and more, it's really good

mpenet11:10:12

had problems with both aleph/http-kit in the past. It was a long time ago for http-kit so maybe it's better now not sure. And aleph the fact it's in life-support + some deadlocks we had makes me reconsider its use

rutledgepaulv14:10:46

i've also had problems with aleph and http-kit and so would recommend clj-http.. unfortunately http-kit doesn't support true response streaming, it buffers the entire response into a byte array regardless of what you request: https://github.com/http-kit/http-kit/issues/90

rutledgepaulv14:10:36

I keep hoping someone will remake a clj-http library on top of OkHttp 🙂. maybe one day I can

borkdude14:10:52

I wonder why the problem in httpkit isn't fixed yet. One should maybe be able to pass in an object that is compatible with http://clojure.java.io which the response gets written to, without keeping it all in memory. That's the approach I took with babashka/process: https://github.com/babashka/process

rutledgepaulv14:10:22

Yeah I'm not sure why but it's one of the main reasons I never use it. Anyone have experience reports with https://github.com/schmee/java-http-clj ?

mpenet14:10:43

it's quite similar to hato, both are very minimalistic, the java api is not bad at all.

mpenet14:10:36

hato I think is somewhat compatible with clj-http api

mpenet14:10:27

I wrote a super thin wrapper for it as well with our specifics, interceptors at the bottom etc (not on gh for now)

borkdude16:10:59

I kind of regret having to make choices of what goes into babashka (right now it contains httpkit since it worked really well with GraalVM), but the Java 11 client space doesn't seem to have a clear winner yet. The java-http library seems simple enough to copy paste and base a babashka.http-client namespace on though, maybe in the future.

borkdude16:10:06

hato really didn't work well with GraalVM, since it has all kinds of dynamic require things. the java-http lib pulls in spec in the core namespace which also isn't great, but at least that's easy to get rid off

mpenet16:10:38

yeah it copied some of this stuff from clj-http I think

mpenet16:10:55

not a fan of dynamic requires either, but I understand the intention

mpenet16:10:08

(clj-http compatiblity)

mpenet16:10:25

aleph does more or less the same

borkdude16:10:17

btw, not async, but I have a very light weight clj-http like wrapper around curl: https://github.com/borkdude/babashka.curl

mpenet16:10:40

I ll see if we could make the repo for our client public eventually

mpenet16:10:09

one cool thing it does is not assuming input/output formats, everything is wired via an interceptor chain, you can use ring1, ring2, or just pain protocol fns depending on the interceptor chain you use with the client. So you can be extremely minimal / low overhead if you need to, or inject some crazy behavior to the chain if you need to

borkdude16:10:30

@U050SC7SV Interested in seeing that

mpenet16:10:19

I ll see on monday if I can have it open

timsgardner01:10:23

that's interesting, what's wrong with pulling in spec @U04V15CAJ?

borkdude07:10:24

@U3Q8MMREX I’m reasoning from the perspective of building a GraalVM native image like babashka. Spec doesn’t yield optimal binaries because it has dynamic requires. But this is easy to fix.

mafcocinco15:11:22

I haven’t seen it mentioned here, but we have used aleph with great success so far. https://github.com/aleph-io/aleph