Liking cljdoc? Tell your friends :D

chord.http-kit


core-async-chclj

(core-async-ch httpkit-ch {:keys [read-ch write-ch format] :as opts})
source

with-channelcljmacro

(with-channel req ch-name & [opts & body])

Extracts the websocket from the request and binds it to 'ch-name' in the body Arguments: req - (required) HTTP-kit request map ch-name - (required) variable to bind the channel to in the body opts - (optional) map to configure reading/writing channels :read-ch - (optional) (possibly buffered) channel to use for reading the websocket :write-ch - (optional) (possibly buffered) channel to use for writing to the websocket :format - (optional) data format to use on the channel, (at the moment) either :edn (default), :json, :json-kw, :transit-json, or :str. (and any other options your formatter needs)

Usage: (require '[clojure.core.async :as a])

(with-channel req the-ws (a/go-loop [] (when-let [msg (a/<! the-ws)] (println msg) (recur))))

(with-channel req the-ws {:read-ch (a/chan (a/sliding-buffer 10)) :write-ch (a/chan (a/dropping-buffer 5))}

(go-loop [] (when-let [msg (<! the-ws)] (println msg) (recur))))

Extracts the websocket from the request and binds it to 'ch-name' in the body
Arguments:
 req         - (required) HTTP-kit request map
 ch-name     - (required) variable to bind the channel to in the body
 opts        - (optional) map to configure reading/writing channels
   :read-ch  - (optional) (possibly buffered) channel to use for reading the websocket
   :write-ch - (optional) (possibly buffered) channel to use for writing to the websocket
   :format   - (optional) data format to use on the channel, (at the moment)
                          either :edn (default), :json, :json-kw, :transit-json, or :str.
      (and any other options your formatter needs)

Usage:
 (require '[clojure.core.async :as a])

 (with-channel req the-ws
   (a/go-loop []
     (when-let [msg (a/<! the-ws)]
       (println msg)
       (recur))))

 (with-channel req the-ws
   {:read-ch (a/chan (a/sliding-buffer 10))
    :write-ch (a/chan (a/dropping-buffer 5))}

   (go-loop []
     (when-let [msg (<! the-ws)]
       (println msg)
       (recur))))
sourceraw docstring

wrap-websocket-handlerclj

(wrap-websocket-handler handler & [opts])

Middleware that puts a :ws-channel key on the request map for websocket requests.

Arguments: handler - (required) Ring-compatible handler opts - (optional) Options for the WebSocket channel - same options as for with-channel

Middleware that puts a :ws-channel key on the request map for
websocket requests.

Arguments:
 handler - (required) Ring-compatible handler
 opts    - (optional) Options for the WebSocket channel - same options as for `with-channel`
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close