Browse files

Added resource-creating helper methods.

  • Loading branch information...
1 parent f50999c commit b86ca9a9fabd10000508e800f8a0b3b1656278e4 @tmciver committed Jan 31, 2013
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/hottop/resource.clj
@@ -40,6 +40,7 @@
:redirect-after-html-post (constantly nil)
:methods {}})
+;; NOTE: rename to 'readonly-html' for next version bump
(defn create-readonly-html-resource
"Returns a resource that will only respond to a GET request. get-fn should be
a function of the ring request. html-fn should be a function of one argument (it
@@ -51,3 +52,14 @@ pass in a single function that takes the ring request and returns HTML directly.
(assoc-in [:content-types-provided "text/html"] html-fn)))
(create-readonly-html-resource get-html-fn identity)))
+(defn add-method-handler
+ "Adds handler to resource for the given HTTP method."
+ [resource method handler]
+ (assoc-in resource [:methods method] handler))
+(defn add-view
+ "Adds view-function to the :content-types-provided map for the key given by
+ [resource content-type view-function]
+ (assoc-in resource [:content-types-provided content-type] view-function))

0 comments on commit b86ca9a

Please sign in to comment.