Created
June 21, 2011 23:06
-
-
Save ibdknox/1039191 to your computer and use it in GitHub Desktop.
get started step 4
This file contains hidden or 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
;; add a value to the session | |
(defpage "/login" {} | |
(session/put! :admin true) | |
(layout | |
[:p "Are you loggedin? "] | |
[:p (session/get :admin)])) | |
;; set a cookie and get its value | |
(defpage "/cookie" [] | |
(cookie/put! :noir "stuff") | |
(let [v (cookie/get :noir)] | |
(layout | |
[:p "You created a cookie:"] | |
[:p "Value " v]))) | |
;; validate our math, if the first statement | |
;; is false, it fails validation and the error | |
;; is added for the given key. | |
(defpage "/validate" [] | |
(vali/rule (= 3 3) | |
[:math "3 != 3"]) | |
(vali/rule (= 1 2) | |
[:math "1 != 2"]) | |
(layout | |
[:p "Let's check your math: "] | |
[:p (str (vali/get-errors :math))])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for newbs, would help to define the proper the requires so the examples just work i.e. for the last example
I'd give you a pull request for the website but that's not really possible with gists