mirror of
https://github.com/metosin/reitit.git
synced 2025-12-16 16:01:11 +00:00
feat: reitit.core/Expand for Vars
This commit is contained in:
parent
659e96e780
commit
5d30a73bad
2 changed files with 12 additions and 1 deletions
|
|
@ -28,6 +28,10 @@
|
|||
:cljs function)
|
||||
(expand [this _] {:handler this})
|
||||
|
||||
#?(:clj clojure.lang.Var
|
||||
:cljs cljs.core.Var)
|
||||
(expand [this _] {:handler this})
|
||||
|
||||
nil
|
||||
(expand [_ _]))
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
(:import (clojure.lang ExceptionInfo)
|
||||
(reitit.core Router))))
|
||||
|
||||
(defn- var-handler [& _]
|
||||
"var-handler")
|
||||
|
||||
(deftest reitit-test
|
||||
|
||||
(testing "routers handling wildcard paths"
|
||||
|
|
@ -245,7 +248,11 @@
|
|||
(let [router (r/router ["/ping" (constantly "ok")])
|
||||
{:keys [result]} (r/match-by-path router "/ping")]
|
||||
(is result)
|
||||
(is (= "ok" (result))))))
|
||||
(is (= "ok" (result))))
|
||||
(testing "var handler gets expanded"
|
||||
(let [router (r/router ["/ping" #'var-handler])
|
||||
{:keys [result]} (r/match-by-path router "/ping")]
|
||||
(is (= #'var-handler result))))))
|
||||
|
||||
(testing "custom router"
|
||||
(let [router (r/router ["/ping"] {:router (fn [_ _]
|
||||
|
|
|
|||
Loading…
Reference in a new issue