Clojure 服务之间的通信

Communication between Clojure services

我需要放置一个 Clojure 服务以通过 HTTP 调用与另一个服务进行通信,在 java 中,我们可以使用 RestTemplate 做类似的事情,如下所示:

             ResponseEntity<Product[]> responseEntity = new RestTemplate().getForEntity(
                    "http://localhost:8001/products/store/all", Product[].class);

在 Clojure 中使用此代码完成相同工作的类似方法是什么?

您可以使用 clj-http and any JSON parser like cheshire:

(ns example
  (:require [clj-http.client :as client]
            [cheshire.core :as :json]))

(def products
   (-> (client/get "http://localhost:8001/products/store/all") 
       (json/parse-string true)))