Permalink
Browse files

Added redirect-after-post function

  • Loading branch information...
1 parent 3fe7c7e commit 11a096e86bd2b9bc105b4dd032bd96265d17c317 @weavejester weavejester committed Jul 2, 2011
Showing with 11 additions and 0 deletions.
  1. +7 −0 ring-core/src/ring/util/response.clj
  2. +4 −0 ring-core/test/ring/util/response_test.clj
View
7 ring-core/src/ring/util/response.clj
@@ -10,6 +10,13 @@
:headers {"Location" url}
:body ""})
+(defn redirect-after-post
+ "Returns a Ring response for an HTTP 303 redirect."
+ [url]
+ {:status 303
+ :headers {"Location" url}
+ :body ""})
+
(defn response
"Returns a skeletal Ring response with the given body, status of 200, and no
headers."
View
4 ring-core/test/ring/util/response_test.clj
@@ -8,6 +8,10 @@
(is (= {:status 302 :headers {"Location" "http://google.com"} :body ""}
(redirect "http://google.com"))))
+(deftest test-redirect-after-post
+ (is (= {:status 303 :headers {"Location" "http://example.com"} :body ""}
+ (redirect-after-post "http://example.com"))))
+
(deftest test-response
(is (= {:status 200 :headers {} :body "foobar"}
(response "foobar"))))

0 comments on commit 11a096e

Please sign in to comment.