Skip to content

Instantly share code, notes, and snippets.

@ibdknox
Created July 24, 2011 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibdknox/1103065 to your computer and use it in GitHub Desktop.
Save ibdknox/1103065 to your computer and use it in GitHub Desktop.
basic defpage
(defpage [:get ["/user/:id" :id #"\d+"]] {:keys [id]}
(str "You are user number " id))
(defpage "/error" []
{:status 500
:body "Oh no! An error has occurred"})
(defpage [:post "/login"] {:keys [username password]}
(str "You tried to login as " username " with the password " password))
(defpage [:post "/"] []
"You posted here!")
(pre-route "/admin/*" {}
(when-not (users/admin?)
(resp/redirect "/login")))
(defpage "/user/:id" {:keys [id]}
(str "You are user number " id))
;; A very simple page definition that maps to the root of your site.
(defpage "/" []
"hello")
(defpage [:get "/"] [] "This is a get") ;; same as (defpage "/" [] ..)
(defpage [:post "/"] [] "This is a post")
(defpage [:put "/"] [] "This is a put")
(defpage [:any "/"] [] "This is any request type")
;; and so on...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment