`with-middleware` rebinds `http/request` with new core client
Open
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 1.8k
- Forks
- 410
- PR merge metrics
- No merged PRs in 30d
Description
If you have a function like this:
(defn make-request
[request]
(http/with-additional-middleware [...]
(http/request request)))
And you call it with mocking, like so:
(binding [http/request (http/make-request (constantly {:status 201}))]
(make-request {...}))
Then the default client (clj-http.core/request) will be used instead of (constantly {:status 201}). This is due to with-middleware rebinding http/request itself
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/clj_http/client.clj around line 1276 and reproduce the issue with the binding and middleware examples in the report. Trace how with-middleware rebinds http/request, then verify that the mocked request remains in use while additional middleware is applied.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100