Setup project as described in previous post
open a terminal window, run lein repl
require the following namespaces
1
2
3
| (require '[vertx.embed :as embed]
'[vertx.eventbus :as eb]
'[vertx.http :as http])
|
set the following system property
1
2
| (System/setProperty "vertx.clusterManagerFactory"
"org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory")
|
set the vertx instance
1
| (embed/set-vertx! (embed/vertx "localhost"))
|
now you can start a server, for example to start a http server do the following
import the http namespace
1
| (require '[vertx.http :as http]))
|
declare a request handler
1
2
3
4
| (defn req-handler [req]
(-> (http/server-response req)
(http/add-header "Content-Type" "text/html; charset=UTF-8")
(http/end "<html><body><h4>It's working!</h4></body></html>")))
|
start server using the handler and assign it to a variable server
1
2
3
| (def server (-> (http/server)
(http/on-request req-handler)
(http/listen 8080 "localhost")))
|