Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns linker.handler
- (:require [compojure.core :refer :all]
- [compojure.route :as route]
- [ring.middleware.defaults :refer [wrap-defaults site-defaults]]))
- (def link-storage {})
- (defn new-link [req]
- (let [params (:params req)
- link (:link params)
- hsh (hash link)]
- (link-storage hsh link)
- (str "Link: " hsh)))
- (defn redirect [hsh]
- (str "LINK: " (hsh link-storage)))
- (defroutes app-routes
- (GET "/" [] "Hello World")
- (GET "/new-link" req new-link)
- (GET "/:hsh" [hsh] (redirect hsh))
- (route/not-found "Not Found"))
- (def app
- (wrap-defaults app-routes site-defaults))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement