Skip to content

Commit

Permalink
fixup! readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenet committed Oct 11, 2023
1 parent f6af6be commit d763f12
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ for clojure, loom based
(require '[s-exp.mina.websocket :as ws])

(def server
(mina/start! { ;; regular ring handler
:http-handler (fn [{:as request :keys [body headers ...]}]
{:status 200
:body "Hello world"
:headers {"Something" "Interesting"}})

;; websocket endpoints
:websocket-endpoints {"/ws" {:message (fn [session data _last-msg]
;; echo back data
(ws/send! session data true))
:open (fn [session] (prn :opening-session))
:close (fn [_session status reason]
(prn :closed-session status reason))
:error (fn [session error]
(prn :error error))
;; :subprotocols ["chat"]
;; :extensions ["foobar"]
;; :http-upgrade (fn [headers] ...)
}}
:port 8080}))
(mina/start! {;; regular ring handler
:http-handler (fn [{:as request :keys [body headers ...]}]
{:status 200
:body "Hello world"
:headers {"Something" "Interesting"}})

;; websocket endpoints
:websocket-endpoints {"/ws" {:message (fn [session data _last-msg]
;; echo back data
(ws/send! session data true))
:open (fn [session] (prn :opening-session))
:close (fn [_session status reason]
(prn :closed-session status reason))
:error (fn [session error]
(prn :error error))
;; :subprotocols ["chat"]
;; :extensions ["foobar"]
;; :http-upgrade (fn [headers] ...)
}}
:port 8080}))
;; ...

(mina/stop! server)
Expand Down

0 comments on commit d763f12

Please sign in to comment.