Processing a stream of messages from a http server in clojure

前端 未结 3 1773
一整个雨季
一整个雨季 2021-01-05 20:10

I am looking for an idiomatic way to do the following. I have a http server that on a particular GET request responds with a stream of messages. Now, since this message is n

3条回答
  •  逝去的感伤
    2021-01-05 20:50

    (ns asyncfun.core
      (:require [clojure.core.async :as async
                 :refer [!! go chan]]
                [clj-http.client :as client]))
    
    (def url "http://hopey.netfonds.no/tradedump.php?date=20150508&paper=AAPL.O&csv_format=txt")
    
    (def out-chan (chan))
    (go (println (!! out-chan (client/get url))
    

    I put this code together in a couple minutes. I think core.async is what you are looking for.

提交回复
热议问题