Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed not-found route to accept response maps

  • Loading branch information...
commit 16322fdb37b9dbc13bfd62bdce503dd13cd94d9f 1 parent aaa3a4b
@weavejester authored
Showing with 14 additions and 5 deletions.
  1. +5 −2 src/compojure/route.clj
  2. +9 −3 test/compojure/test/route.clj
View
7 src/compojure/route.clj
@@ -1,6 +1,7 @@
(ns compojure.route
+ (:require [compojure.response :as response])
(:use compojure.core
- [ring.util.response :only (file-response resource-response)]
+ [ring.util.response :only (file-response resource-response status)]
[ring.util.codec :only (url-decode)]
ring.middleware.content-type
ring.middleware.file-info))
@@ -37,4 +38,6 @@
[body]
(routes
(HEAD "*" [] {:status 404})
- (ANY "*" [] {:status 404, :body body})))
+ (ANY "*" {:as request}
+ (-> (response/render body request)
+ (status 404)))))
View
12 test/compojure/test/route.clj
@@ -4,9 +4,15 @@
(:require [compojure.route :as route] :reload))
(deftest not-found-route
- (let [response ((route/not-found "foo") (request :get "/"))]
- (is (= (:status response) 404))
- (is (= (:body response) "foo"))))
+ (testing "string body"
+ (let [response ((route/not-found "foo") (request :get "/"))]
+ (is (= (:status response) 404))
+ (is (= (:body response) "foo"))))
+ (testing "response map body"
+ (let [response ((route/not-found {:status 200 :body "bar"})
+ (request :get "/"))]
+ (is (= (:status response) 404))
+ (is (= (:body response) "bar")))))
(deftest resources-route
(let [route (route/resources "/foo" {:root "resources"})
Please sign in to comment.
Something went wrong with that request. Please try again.