Last active
August 29, 2015 14:04
-
-
Save dbushenko/27282f6d3c4043875d7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; That one works: | |
(defroutes all-routes | |
(GET "/req" req (str req))) | |
(def endpoint {:on-message (fn [channel message] | |
(websocket-message-received message channel)) | |
:on-close (fn [channel {:keys [code reason]}] | |
(websocket-channel-closed channel code))}) | |
(defn websock-create [] | |
(ws/create-handler endpoint)) | |
(defn -main [& args] | |
(run (websock-create) | |
:host (config :host) :port (config :port) :path "/ws") ;; I connect to "ws://127.0.0.1:8080/ws" -- works | |
(run (-> all-routes | |
wrap-session | |
reload/wrap-reload) | |
:host (config :host) :port (config :port) :path "/")) | |
;; Code below is worse: | |
(defn -main [& args] | |
(let [latch (promise) | |
servlet (create-servlet all-routes)] | |
(run (attach-endpoint servlet | |
(create-endpoint endpoint)) | |
:host (config :host) :port (config :port) :path "/"))) | |
;; Ring handler all-routes works, but I can't connect to websocket to URL "ws://127.0.0.1:8080" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment