Skip to content

Instantly share code, notes, and snippets.

@gtrak
Created August 16, 2012 18:30
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 gtrak/3372429 to your computer and use it in GitHub Desktop.
Save gtrak/3372429 to your computer and use it in GitHub Desktop.
Compojure demo
(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