diff options
-rw-r--r-- | project.clj | 6 | ||||
-rw-r--r-- | src/abra/core.clj (renamed from src/reverse_routing/core.clj) | 11 | ||||
-rw-r--r-- | test/abra/core_test.clj (renamed from test/reverse_routing/core_test.clj) | 4 |
3 files changed, 15 insertions, 6 deletions
diff --git a/project.clj b/project.clj index 431b954..4c96e79 100644 --- a/project.clj +++ b/project.clj @@ -1,6 +1,6 @@ -(defproject reverse-routing "0.1.0-SNAPSHOT" - :description "FIXME: write description" - :url "http://example.com/FIXME" +(defproject abra "0.1.0-SNAPSHOT" + :description "A small library for reverse-routing in compojure applications." + :url "http://bitbucket.org/czan/abra" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.5.1"] diff --git a/src/reverse_routing/core.clj b/src/abra/core.clj index edc1f57..3d373eb 100644 --- a/src/reverse_routing/core.clj +++ b/src/abra/core.clj @@ -1,4 +1,4 @@ -(ns reverse-routing.core +(ns abra.core (:require clout.core compojure.core [clojure.string :as string])) @@ -69,6 +69,15 @@ (= (count args#) (count ~(vec route-args)))) ~routes-map))))) +(defn add-middleware [handler middleware & args] + (let [result (apply middleware handler args)] + (vary-meta result + assoc ::lookup (fn [[name args]] + (let [lookup-fn (-> (deref-if-var handler) + meta + ::lookup)] + (lookup-fn [name args])))))) + (defmacro with-url-fn [f & body] `(binding [*lookup-route* (fn [x#] (apply ~f x#)) *root* ""] diff --git a/test/reverse_routing/core_test.clj b/test/abra/core_test.clj index fb37c94..b829cec 100644 --- a/test/reverse_routing/core_test.clj +++ b/test/abra/core_test.clj @@ -1,6 +1,6 @@ -(ns reverse-routing.core-test +(ns abra.core-test (:use clojure.test - reverse-routing.core + abra.core [compojure.core :only [GET]])) (defn make-request [handler uri] |