Skip to content

Commit 3123e86

Browse files
committed
update README
1 parent f6ea72b commit 3123e86

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,21 @@ Whenever you make an http request, add one or more of the hystrix-clj options to
2626
:hystrix/breaker-sleep-window-ms 5000
2727
:hystrix/bad-request-pred client-error?})
2828
```
29-
Any values not supplied will be set to their default values as above. Requests with no Hystrix-related keys won't use Hystrix.
29+
30+
Requests without any `:hystrix/...` keys won't use Hystrix. Any values not supplied will be set to their default values as above. Custom default values can also be specified when registering with `add-hook`:
31+
32+
```clj
33+
(clj-http-hystrix.core/add-hook {:hystrix/timeout-ms 2500
34+
:hystrix/queue-size 12})
35+
36+
;; now each request will fallback to these if not supplied
37+
(http/get "http://www.google.com" {:hystrix/command-key :google})
38+
;;=> {:hystrix/command-key :google
39+
;; :hystrix/timeout-ms 2500
40+
;; :hystrix/queue-size 12
41+
;; ... (rest are clj-http-hystrix defaults)
42+
;; }
43+
```
3044

3145
## Bad requests
3246

src/clj_http_hystrix/core.clj

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,15 @@
111111
(let [req (merge defaults req)
112112
bad-request-pred (:hystrix/bad-request-pred req)
113113
fallback (:hystrix/fallback-fn req)
114-
wrap-bad-request (fn [resp] (if (bad-request-pred req resp)
115-
(throw
116-
(HystrixBadRequestException.
117-
"Ignored bad request"
118-
(wrap {:object resp
119-
:message "Bad request pred"
120-
:stack-trace (stack-trace)})))
121-
resp))
114+
wrap-bad-request (fn [resp]
115+
(if (bad-request-pred req resp)
116+
(throw
117+
(HystrixBadRequestException.
118+
"Ignored bad request"
119+
(wrap {:object resp
120+
:message "Bad request pred"
121+
:stack-trace (stack-trace)})))
122+
resp))
122123
wrap-exception-response (fn [resp]
123124
((http/wrap-exceptions (constantly resp))
124125
(assoc req :throw-exceptions true)))

0 commit comments

Comments
 (0)