Skip to content

Commit

Permalink
clojure balancer result api for #286
Browse files Browse the repository at this point in the history
  • Loading branch information
xfeep committed May 14, 2023
1 parent 09b3753 commit 3f0cfa6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/clojure/nginx/clojure/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,15 @@ When a message comes the callback function will be invoked. e.g.
(callback message att))))]
(fn [] (.unsubscribe topic pd))))
(destory! [topic] (.destory topic)))

(defn balancer-result
"Build a balancer result for a load balancer.
`idx-or-url can be an index of the upstream servers list or the url string.
e.g. (balancer-result 3) , (balancer-result \"192.168.3.5:8071\")
"
[idx-or-url]
(cond
(instance? String idx-or-url) {:status 200, :body idx-or-url}
(instance? Integer idx-or-url) {:status 200, :body idx-or-url}
:else
{:status 500}))

0 comments on commit 3f0cfa6

Please sign in to comment.