Clojure 如何配置同级基座布线,以便在使用:约束时可以访问所有布线?

Clojure 如何配置同级基座布线,以便在使用:约束时可以访问所有布线?,clojure,pedestal,Clojure,Pedestal,我正在创建一个玩具底座服务,旨在拥有以下资源: / /movies /movies/today /movies/:iso日期其中:iso日期匹配####-##-## 最后一条管线的约束由以下代码段定义: ^:constraints {:iso-date #"\d{4}-\d{2}-\d{2}"} 无论何时包含此约束的路由出现在路由表中,我都无法获取其同级路由/movies/today;相反,我得到了一个“未找到”的响应。然而,当具有路由的约束被移除时,获取/movies/today成功 我

我正在创建一个玩具底座服务,旨在拥有以下资源:

  • /
  • /movies
  • /movies/today
  • /movies/:iso日期
    其中
    :iso日期
    匹配####-##-##
最后一条管线的约束由以下代码段定义:

^:constraints {:iso-date #"\d{4}-\d{2}-\d{2}"}
无论何时包含此约束的路由出现在路由表中,我都无法获取其同级路由
/movies/today
;相反,我得到了一个“未找到”的响应。然而,当具有路由的约束被移除时,获取
/movies/today
成功

我使用简洁的格式定义的基座布线如下所示:

(defroutes routes
  [[["/" {:get root-page}
     ["/movies" ^:interceptors [fetch-movies]
      {:get movies-page}
      ["/today" {:get movies-for-today-page}]
      ["/:iso-date" ^:constraints {:iso-date #"\d{4}-\d{2}-\d{2}"}
       {:get movies-for-date-page}]]]]])
为了实现我想要的路由行为,我是否正确构建了这个路由表

注意:打印已编译的路由会给我预期的结果,因为所有路由都存在生成的
:path re
正则表达式与REPL:

({:path-parts [""],
  :path-params [],
  :interceptors
  [{:name :foobar.service/root-page,
    :enter
    #object[io.pedestal.interceptor.helpers$before$fn__7359 0x14501070 "io.pedestal.interceptor.helpers$before$fn__7359@14501070"],
    :leave nil,
    :error nil}],
  :path "/",
  :method :get,
  :path-re #"/\Q\E",
  :route-name :foobar.service/root-page}
 {:path-parts ["" "movies"],
  :path-params [],
  :interceptors
  [{:name :foobar.service/fetch-movies,
    :enter
    #object[io.pedestal.interceptor.helpers$on_request$fn__7401 0x2aa85cc4 "io.pedestal.interceptor.helpers$on_request$fn__7401@2aa85cc4"],
    :leave nil,
    :error nil}
   {:name :foobar.service/movies-page,
    :enter
    #object[io.pedestal.interceptor.helpers$before$fn__7359 0x30ffc3c0 "io.pedestal.interceptor.helpers$before$fn__7359@30ffc3c0"],
    :leave nil,
    :error nil}],
  :path "/movies",
  :method :get,
  :path-re #"/\Qmovies\E",
  :route-name :foobar.service/movies-page}
 {:path-parts ["" "movies" "today"],
  :path-params [],
  :interceptors
  [{:name :foobar.service/fetch-movies,
    :enter
    #object[io.pedestal.interceptor.helpers$on_request$fn__7401 0x2aa85cc4 "io.pedestal.interceptor.helpers$on_request$fn__7401@2aa85cc4"],
    :leave nil,
    :error nil}
   {:name :foobar.service/movies-for-today-page,
    :enter
    #object[io.pedestal.interceptor.helpers$before$fn__7359 0x3726fc3b "io.pedestal.interceptor.helpers$before$fn__7359@3726fc3b"],
    :leave nil,
    :error nil}],
  :path "/movies/today",
  :method :get,
  :path-re #"/\Qmovies\E/\Qtoday\E",
  :route-name :foobar.service/movies-for-today-page}
 {:path-parts ["" "movies" :iso-date],
  :path-params [:iso-date],
  :interceptors
  [{:name :foobar.service/fetch-movies,
    :enter
    #object[io.pedestal.interceptor.helpers$on_request$fn__7401 0x2aa85cc4 "io.pedestal.interceptor.helpers$on_request$fn__7401@2aa85cc4"],
    :leave nil,
    :error nil}
   {:name :foobar.service/movies-for-date-page,
    :enter
    #object[io.pedestal.interceptor.helpers$before$fn__7359 0x93fb20b "io.pedestal.interceptor.helpers$before$fn__7359@93fb20b"],
    :leave nil,
    :error nil}],
  :path "/movies/:iso-date",
  :path-constraints {:iso-date "(\\d{4}-\\d{2}-\\d{2})"},
  :query-constraints {},
  :method :get,
  :path-re #"/\Qmovies\E/(\d{4}-\d{2}-\d{2})",
  :route-name :foobar.service/movies-for-date-page})

我在0.4.1-SNAPSHOT版本中解决了这个问题

(io.desidel.http.route/router我的路由:线性搜索)

使用
:线性搜索
,而不是
:前缀树