Created
August 16, 2012 18:30
-
-
Save gtrak/3372429 to your computer and use it in GitHub Desktop.
Compojure demo
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
(defn OPTIONS | |
"Generate a OPTIONS route with the given response." | |
[response] | |
(fn [request] | |
(when (= (:request-method request) :options) | |
response))) | |
(defroutes routes | |
(GET "/" [] "<h1>Hello World</h1>") | |
(context (:registry contexts) [] registry) | |
(context (:dataset contexts) [] dataset) | |
(OPTIONS (-> (rr/response nil) | |
(rr/header "Allow" | |
(s/join ", " ["GET" "POST" "HEAD" "PUT" | |
"TRACE" "OPTIONS" "DELETE"])))) | |
(route/not-found "<h1>Page not found</h1>")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment