-
-
Save viksit/15464b3bbd6b70b7478d to your computer and use it in GitHub Desktop.
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
(defroutes routes | |
(GET "/" [] "<h2>Foob</h2>") | |
(GET "/user/:id" [id] | |
(str "<h1>Hello user " id "</h1>")) | |
(GET "/sample" {params :params} | |
(do | |
(prn params) | |
(str "---> " params))) | |
(GET "/posts" req | |
(let [title (get (:params req) "title") | |
author (get (:params req) "author")] | |
(do | |
(prn req) | |
(str "Title: " title ", Author222: " author))))) | |
(def myapp | |
(-> routes | |
wrap-params)) | |
(defonce server (ring/run-jetty #'myapp {:port 9000 :join? false})) | |
(defn start-server [] | |
(.start server)) | |
(defn stop-server [] | |
(.stop server)) | |
(defn -main [] | |
(start-server)) | |
--- | |
http://localhost:9000/sample?a=1 | |
-->{} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment