Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pluggable HTTP client #98

Open
greglook opened this issue Nov 28, 2022 · 2 comments
Open

Support pluggable HTTP client #98

greglook opened this issue Nov 28, 2022 · 2 comments

Comments

@greglook
Copy link
Collaborator

In its initial incarnation, vault-clj used the clj-http client, which is built on Apache's http client. Later, for compatibility with babashka (and graal) this switched to http-kit, which is much lighter-weight. Some consumers may still want a simpler approach and fewer dependencies, and Java 11+ comes with a new built-in HttpClient class. Ideally, we could structure the client so that users could select among several HTTP clients, or even implement their own.

The main thing necessary to fit into the current control flow logic is for the client to be able to operate asynchronously and invoke on-success or on-error callbacks, similar to how http-kit works.

@greglook greglook added this to the 2.x milestone Nov 28, 2022
@greglook
Copy link
Collaborator Author

greglook commented Sep 8, 2023

Still an interesting idea, but not going to block 2.x on this.

@greglook greglook removed this from the 2.x milestone Sep 8, 2023
@jasonjckn
Copy link

jasonjckn commented Sep 16, 2023

fyi, i have to fork & remove httpkit because it had an obscure bug , we're on hato http client / jdk11 now :)

Less important but not without merit, is jsonista performs much better than data.json, from what I understand.

Off the top of my head, I can't remember how pervasive data.json is in the code base, but if its only ever used for HTTP response parsing, you could put both HTTP Client & JSON lib, into the the same abstraction.

The interface could be ~ http/request with an as implicit :as json that's implementation dependent, and/or use multimethods to allow extensible :as (maybe related to #100)

--

do you have any preferred approach to supporting optional library dependencies?

If you still want to dynamically refer to hato/clj-http/httpkit in the code, i've seen approaches that use requiring-resolve, eval, Class/forName,

Or you can just not refer to any particular library in the code, e.g. multimethods, protocols, slf4j-api style, polylith-style, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants