dakrone / dakrone/clj-http

`with-middleware` rebinds `http/request` with new core client

Open
#644 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.