Last active
May 18, 2016 05:27
-
-
Save bendyorke/7c6e68076376b95cba6770982e788b6f to your computer and use it in GitHub Desktop.
Playing around with zero_to_clojure.clj
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
#! /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