Skip to content

Commit

Permalink
Verify wrap-websocket is truly MIDDLEware now, either in or out-of-co…
Browse files Browse the repository at this point in the history
…ntainer
  • Loading branch information
jcrossley3 committed Jan 16, 2015
1 parent 188c095 commit 1d34a27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions web/dev-resources/testing/app.clj
Expand Up @@ -102,8 +102,8 @@

(defn run []
(web/run (-> #'routes
wrap-session
(wrap-websocket
:on-open #'on-open-set-handshake
:on-message #'on-message-send-handshake)))
:on-message #'on-message-send-handshake)
wrap-session))
(web/run (-> ws-as-channel wrap-session) :path "/ws"))
14 changes: 5 additions & 9 deletions web/src/immutant/web/middleware.clj
Expand Up @@ -82,15 +82,11 @@
* :on-error `(fn [channel throwable])`
If handler is nil, a 404 status will be returned for any
non-websocket request.
If called within a servlet container, e.g. WildFly, this should be
the last call in your middleware chain, as its result will be a
servlet, not a function."
non-websocket request."
([handler key value & key-values]
(wrap-websocket handler (apply hash-map key value key-values)))
(wrap-websocket handler (apply hash-map key value key-values)))
([handler callbacks]
(fn [request]
(if (:websocket? request)
(as-channel request callbacks)
(merge {:status 404} (when handler (handler request)))))))
(if (:websocket? request)
(as-channel request callbacks)
(merge {:status 404} (when handler (handler request)))))))

0 comments on commit 1d34a27

Please sign in to comment.