Thanks a lot
we modify the hello code to following:

(ns examples.simple-http-server)

(require
 '[io.vertx.clojure.core.core :as core]
 '[io.vertx.lang.clojure.vertx :as vertx]
 '[io.vertx.lang.clojure.http-server :as server]
 '[io.vertx.lang.clojure.http-server-request :as request]
 '[io.vertx.lang.clojure.http-server-response :as response])

(defn handle-request [req]
  (let [response (request/response req)]
    (response/put-header response "content-type" "text/plain")
    (response/end response "Hello from Vert.x!")))

(defn start [vertx]
  (let [http-server (vertx/create-http-server vertx)]
    (server/request-handler http-server (core/handler handle-request))
    (server/listen http-server 8080)))


and we also have one problem

On Wednesday, January 10, 2018 at 6:52:53 PM UTC+8, Gary Verhaegen wrote:
>
> It’s not clear what the "do" is supposed to mean in those defns (unless 
> there’s some deep dark magic going on, they are currently not doing 
> anything and you can just remove them), and you very likely want "let" 
> instead of "def" for the local variables.
>
> def in Clojure does not follow lexical scoping rules; it’s always a global 
> name.
>
> On 10 Jan 2018, at 10:25, Feuer Au <chenge...@gmail.com <javascript:>> 
> wrote:
>
> And here is the simple example "Hello from Vert.x!" like other languages 
> on the Vert.x official frontpage:
>
> (ns examples.simple-http-server)
>
> (require
>  '[io.vertx.clojure.core.core :as core]
>  '[io.vertx.lang.clojure.vertx :as vertx]
>  '[io.vertx.lang.clojure.http-server :as server]
>  '[io.vertx.lang.clojure.http-server-request :as request]
>  '[io.vertx.lang.clojure.http-server-response :as response])
>
> (defn handle-request [req]
>   do
>   (def response (request/response req))
>   (response/put-header response "content-type" "text/plain")
>   (response/end response"Hello from Vert.x!"))
>
> (defn start [vertx]
>   do
>   (def http-server (vertx/create-http-server vertx))
>   (server/request-handler http-server (core/handler handle-request))
>   (server/listen http-server 8080))
>
> Pretty straight forward, but we could make it better
> e.g. combine different namespaces into one single would be nice 
> and we got pure functions in different namespaces 
> hmmm...., it looks nice.
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com <javascript:>
> Note that posts from new members are moderated - please be patient with 
> your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com <javascript:>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+u...@googlegroups.com <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to