Browse files

Added compojure.route/files function

  • Loading branch information...
1 parent b5809d2 commit 6d603824c9477c903ed04141caebc229215a84ab @weavejester committed Apr 25, 2010
Showing with 16 additions and 0 deletions.
  1. +16 −0 src/compojure/route.clj
View
16 src/compojure/route.clj
@@ -0,0 +1,16 @@
+(ns compojure.route
+ (:use compojure.core
+ [ring.util.response :only (file-response)]
+ [ring.util.codec :only (url-decode)]))
+
+(defn- add-wildcard
+ "Add a wildcard to the end of a route path."
+ [path]
+ (str path (if (.endsWith path "/") "*" "/*")))
+
+(defn files
+ "A route for serving static files from a directory."
+ [path & [options]]
+ (GET (add-wildcard path) {{file-path "*"} :params}
+ (let [options (merge {:root "public"} options)]
+ (file-response file-path options))))

0 comments on commit 6d60382

Please sign in to comment.