Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added github enhancement #1: change value of resource key

:redirect-after-html-post from URI string to a function of the Ring
request. Clean up and add to the comment doc in resource.clj. Bumped
version to 0.1.3 as this is a breaking API change.
  • Loading branch information...
commit a6e31cc99cccf22b04ac97d42a9d1dc4f0177096 1 parent cb75628
@tmciver authored
Showing with 14 additions and 8 deletions.
  1. +1 −1  project.clj
  2. +1 −1  src/hottop/proc.clj
  3. +12 −6 src/hottop/resource.clj
View
2  project.clj
@@ -1,4 +1,4 @@
-(defproject hottop/hottop "0.1.2"
+(defproject hottop/hottop "0.1.3"
:min-lein-version "2.0.0"
:profiles {:dev
{:dependencies
View
2  src/hottop/proc.clj
@@ -111,7 +111,7 @@ web browser."
result (post-fn request)]
(if (util/response? result)
result
- (let [redirect-uri (:redirect-after-html-post resource)]
+ (let [redirect-uri ((:redirect-after-html-post resource) request)]
(if (and redirect-uri (util/accepts-html? request))
(ring/redirect-after-post redirect-uri)
(response/code 200))))))
View
18 src/hottop/resource.clj
@@ -15,23 +15,29 @@
;; functions of a single argument. These functions are intended to convert
;; data from the client into a more usable format (This needs to be defined
;; better).
+;; :auth
+;; A function whose only argument is the Ring request and which should
+;; return true if the user is authorized to access this resource, false
+;; otherwise.
;; :languages-provided
;; A set of strings representing language codes. Defaults to #{"en" "en-us"}.
+;; :redirect-after-html-post
+;; A function of the Ring request that returns a URI string to which the
+;; client will be redirect (via a 303 response). This occurs only if 1. the
+;; user supplies a redirect URI and 2. if the client lists either or both of
+;; 'text/html' or 'application/xhtml+xml' in the Accept header.
;; :methods
;; A map of HTTP method keywords to functions. The function associated with a
;; method should take one argument which will be the Ring request. The return
;; value can be any application-specific data structure. The returned data
;; structure will be passed to the function associated with the optimal
;; internet media type found in the :content-types-provided map.
-;; :auth
-;; A function whose only argument is the Ring request and which should
-;; return true if the user is authorized to access this resource, false
-;; otherwise.
+
(def base-resource {:content-types-provided {}
- :content-types-accepted {"application/x-www-form-urlencoded" 'some-fn-to-parse-like-from-Ring}
+ :content-types-accepted {}
:auth (constantly true)
:languages-provided #{"en" "en-us"}
- :redirect-after-html-post nil
+ :redirect-after-html-post (constantly nil)
:methods {}})
(defn create-readonly-html-resource
Please sign in to comment.
Something went wrong with that request. Please try again.