Fix WebSocket price stream by guarding nil responses from ring-defaults
ring-defaults middleware (wrap-content-type, wrap-xss-protection) was converting the nil response from the raw WebSocket upgrade handler into a partial response map (headers only, no status), causing the Undertow adapter to attempt ending the already-upgraded exchange. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,14 @@
|
|||||||
(update resp :headers assoc
|
(update resp :headers assoc
|
||||||
"Access-Control-Allow-Origin" origin)))))
|
"Access-Control-Allow-Origin" origin)))))
|
||||||
|
|
||||||
|
(defn- wrap-nil-guard
|
||||||
|
"Discard responses with no :status — these are artifacts of ring-defaults
|
||||||
|
middleware wrapping a nil response (e.g., from a raw WebSocket upgrade)."
|
||||||
|
[handler]
|
||||||
|
(fn [request]
|
||||||
|
(let [resp (handler request)]
|
||||||
|
(when (:status resp) resp))))
|
||||||
|
|
||||||
(defn wrap-base [{:keys [site-defaults-config cors-origin]}]
|
(defn wrap-base [{:keys [site-defaults-config cors-origin]}]
|
||||||
(let [origin (or cors-origin
|
(let [origin (or cors-origin
|
||||||
(System/getenv "CORS_ORIGIN")
|
(System/getenv "CORS_ORIGIN")
|
||||||
@@ -24,4 +32,5 @@
|
|||||||
(-> handler
|
(-> handler
|
||||||
(defaults/wrap-defaults
|
(defaults/wrap-defaults
|
||||||
(or site-defaults-config defaults/api-defaults))
|
(or site-defaults-config defaults/api-defaults))
|
||||||
|
(wrap-nil-guard)
|
||||||
(wrap-cors origin)))))
|
(wrap-cors origin)))))
|
||||||
|
|||||||
Reference in New Issue
Block a user