Skip to content
Browse files

Fixed file and resource routes

  • Loading branch information...
1 parent b9ecce5 commit 8c2ee9751a1d462d5bdc8648e1cd10b94c9c03eb @weavejester committed Dec 29, 2010
Showing with 5 additions and 4 deletions.
  1. +2 −2 src/compojure/route.clj
  2. +3 −2 test/compojure/test/route.clj
View
4 src/compojure/route.clj
@@ -13,7 +13,7 @@
keys:
:root - the root path where the files are stored. Defaults to 'public'."
[path & [options]]
- (GET (add-wildcard path) {{file-path "*"} :params}
+ (GET (add-wildcard path) {{file-path :*} :route-params}
(let [options (merge {:root "public"} options)]
(file-response file-path options))))
@@ -22,7 +22,7 @@
keys:
:root - the root prefix to get the resources from. Defaults to '/public'."
[path & [options]]
- (GET (add-wildcard path) {{resource-path "*"} :params}
+ (GET (add-wildcard path) {{resource-path :*} :route-params}
(let [options (merge {:root "/public"} options)]
(resource-response resource-path options))))
View
5 test/compojure/test/route.clj
@@ -1,15 +1,16 @@
(ns compojure.test.route
(:use clojure.test
+ ring.mock.request
[clojure.contrib.io :only (slurp*)])
(:require [compojure.route :as route]))
(deftest not-found-route
- (let [response ((route/not-found "foo") {})]
+ (let [response ((route/not-found "foo") (request :get "/"))]
(is (= (:status response) 404))
(is (= (:body response) "foo"))))
(deftest resources-route
(let [route (route/resources "/foo" {:root "/resources"})
- response (route {:request-method :get, :uri "/foo/test.txt"})]
+ response (route (request :get "/foo/test.txt"))]
(is (= (:status response) 200))
(is (= (slurp* (:body response)) "foobar\n"))))

0 comments on commit 8c2ee97

Please sign in to comment.
Something went wrong with that request. Please try again.