Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Pull back on ring.branch, needs some proving in other apps before bei…

…ng merged into Ring core
  • Loading branch information...
commit eae70f9c8696a6919e79073b8f4257b20e6ab621 1 parent 843c0a9
@mmcgrana authored
View
1  README.textile
@@ -28,7 +28,6 @@ To see a more sophisticated Ring app, run:
h2. All Available Libs
* @ring.jetty@: Handler for the Jetty webserver.
- * @ring.branch@: Middleware that proxies to one of multiple backing apps depending on the request uri.
* @ring.file@: Middleware that serves static files out of a public directory.
* @ring.file-info@: Middleware that augments response headers with info about File responses.
* @ring.static@: Middleware that serves static files with specified prefixes out of a public directory.
View
24 src/ring/branch.clj
@@ -1,24 +0,0 @@
-(ns ring.branch)
-
-(defn wrap
- "Returns an app that proxies to one of several possible backing apps depending
- on the beginning of the request uri.
- Should be passed an odd number of arguments - the inital pairs of arguments
- indicate the branching conditions and corresponding apps, and the last
- argument the fallback app that will be invoked if none of the branching
- conditions are met:
-
- (wrap [\"/javascripts\" \"stylesheets\"] static-app
- [\"/blog\"] blog-app
- dynamic-app)"
- [& branching]
- (let [fallback (last branching)
- branch-logic
- (map (fn [[prefixes branch]]
- (fn [req]
- (let [uri (:uri req)]
- (if (some #(.startsWith uri %) prefixes) (branch req)))))
- (partition 2 branching))]
- (fn [req]
- (or (some #(% req) branch-logic)
- (fallback req)))))
View
15 test/ring/branch_test.clj
@@ -1,15 +0,0 @@
-(ns ring.branch-test
- (:use clj-unit.core ring.branch))
-
-(def wrapped
- (wrap ["/javascripts" "/stylesheets"] (fn [req] [req :static])
- ["/blog"] (fn [req] [req :blog])
- (fn [req] [req :dynamic])))
-
-(deftest "wrap"
- (let [req {:uri "/stylesheets"}]
- (assert= [req :static] (wrapped req)))
- (let [req {:uri "/blog/foo"}]
- (assert= [req :blog] (wrapped req)))
- (let [req {:uri "/foo/blog"}]
- (assert= [req :dynamic] (wrapped req))))
View
1  test/run.clj
@@ -6,6 +6,5 @@
'ring.file-test
'ring.file-info-test
'ring.static-test
- 'ring.branch-test
'ring.reload-test
'ring.backtrace-test)
Please sign in to comment.
Something went wrong with that request. Please try again.