Browse files

Fixed github issue #2: if return value of post function call is a res…


return it, otherwise go on to do the check for a redirect as before.
  • Loading branch information...
1 parent ae8b018 commit cb75628d3bdfccf65bdebc8e2ed3951bd2248b0e @tmciver committed Jan 29, 2013
Showing with 15 additions and 6 deletions.
  1. +8 −6 src/hottop/proc.clj
  2. +7 −0 src/hottop/util.clj
@@ -107,9 +107,11 @@ but this function will respond with a redirect under the following circumstances
type returned by util/optimal-media-type is one of 'text/html' or
'application/xhtml+xml'. This is to give the right behavior when the client is a
web browser."
- (let [post-fn (get-in resource [:methods :post])]
- (post-fn request)
- (let [redirect-uri (:redirect-after-html-post resource)]
- (if (and redirect-uri (util/accepts-html? request))
- (ring/redirect-after-post redirect-uri)
- (response/code 200)))))
+ (let [post-fn (get-in resource [:methods :post])
+ result (post-fn request)]
+ (if (util/response? result)
+ result
+ (let [redirect-uri (:redirect-after-html-post resource)]
+ (if (and redirect-uri (util/accepts-html? request))
+ (ring/redirect-after-post redirect-uri)
+ (response/code 200))))))
@@ -72,3 +72,10 @@ for examples of media type strings.
+(defn response?
+ "Returns truthy if argument is a map that contains the key :status, false
+ [data]
+ (and (map? data)
+ (some #{:status} (keys data))))

0 comments on commit cb75628

Please sign in to comment.