Skip to content

Instantly share code, notes, and snippets.

@bendyorke
Last active May 18, 2016 05:27
Show Gist options
  • Save bendyorke/7c6e68076376b95cba6770982e788b6f to your computer and use it in GitHub Desktop.
Save bendyorke/7c6e68076376b95cba6770982e788b6f to your computer and use it in GitHub Desktop.
Playing around with zero_to_clojure.clj
#! /usr/bin/env boot
(set-env! :dependencies '[[compojure "1.5.0"]
[http-kit "2.1.8"]])
;; You can pass as many packages as you want to require,
;; so no need to invoke it twice!
(require '[compojure.core :refer [defroutes GET POST]]
'[org.httpkit.server :refer [run-server]])
(defn greet [greetee]
(str "<h1>Hello " greetee "!</h1>"))
(defroutes routes
(GET "/" []
(greet "World"))
(GET "/:name" [name]
(greet name))
(POST "/print/:message" [message]
(println message)))
(defn -main [] ;; boot executables run -main by default
(println "Starting server on port 9001...")
(run-server routes {:port 9001})
(println "Server started")
(boot (wait)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment