Clojure 如何设置默认路由?
使用Clojure 如何设置默认路由?,clojure,Clojure,使用compojure如何设置默认路由,例如 (defroutes app (GET '/api/user/:id/' [] show-user) (default-handler render-template)) ; this is what I want 有没有办法做到这一点?我知道未找到,但它给我404 http状态。您只需将处理程序设置为/: (defroutes app (GET "/api/user/:id/" [] show-user) (GET "/" ren
compojure
如何设置默认路由,例如
(defroutes app
(GET '/api/user/:id/' [] show-user)
(default-handler render-template)) ; this is what I want
有没有办法做到这一点?我知道
未找到
,但它给我404 http状态。您只需将处理程序设置为/
:
(defroutes app
(GET "/api/user/:id/" [] show-user)
(GET "/" render-template))
或者,如果要默认任何HTTP谓词:
(defroutes app
(GET "/api/user/:id/" [] show-user)
(ANY "/" render-template))
Compojure路由自上而下匹配,因此任何未匹配的内容都将返回到您的
/
处理程序。您只需将处理程序设置为/
:
(defroutes app
(GET "/api/user/:id/" [] show-user)
(GET "/" render-template))
或者,如果要默认任何HTTP谓词:
(defroutes app
(GET "/api/user/:id/" [] show-user)
(ANY "/" render-template))
Compojure路由自上而下匹配,因此任何未匹配的内容都将返回到您的
/
处理程序。我认为这不再是事实。我认为您需要(任何“*”渲染模板)。我认为这不再是事实。我认为您需要(任何“*”渲染模板)。