我正在使用 compojure-api,我正在寻找一个函数,给定我的 api 路由结构和请求,返回该请求的路由记录(或:名称),而不应用其处理程序。
我已经能够在 compojure.api.routes/path-for 中找到与我正在寻找的相反的东西,给定一个 :name,它会返回相应路由的路径。在同一个命名空间中,还有像 get-routes 这样看起来很有前途的功能,但我还没有找到我正在寻找的东西。
换句话说,给定这个简单的例子
(defapi my-api
(context "/" []
(GET "/myroute" request
:name :my-get
(ok))
(POST "/myroute" request
:name :my-post
(ok))))
我正在寻找一个像这样工作的函数 foo
(foo my-api (mock/request :get "/myroute"))
;; => #Route{:path "/myroute", :method :get, :info {:name :my-get, :public {:x-name :my-get}}}
;; or
;; => :my-get
有任何想法吗?