ngrunwald / ring-middleware-format

Ring middleware for parsing parameters and emitting responses in JSON or other formats
163 stars 49 forks source link

Compatibility with Immutant websocket middleware #46

Open Deraen opened 9 years ago

Deraen commented 9 years ago

https://github.com/immutant/immutant/blob/2.0.0-beta1/web/src/immutant/web/websocket.clj#L72

In Immutant websocket connection can be initialized from middleware or from standard ring handler. In former case it's possible to reorder middlewares so that r-m-f doesn't see the response from websocket middleware.

Another solution is to provide custom predicate to wrap-restful-response:

(defn serializable?
  [{:keys [websocket?] :as request} {:keys [body] :as response}]
  (when response
    (not (or
          websocket?
          (string? body)
          (instance? File body)
          (instance? InputStream body)))))