Compojure路由问题

4

我有一个小的compojure网站,路由定义如下:

(defroutes example
  (GET "/" [] {:status 200
               :headers {"Content-Type" "text/html"}
               :body (home)})
  (GET "/*" (or (serve-file (params :*)) :next))
  (GET "/execute/" [] {:status 200
                      :headers {"Content-Type" "text/html"}
                      :body (execute-changes)})
  (GET "/status/" [] {:status 200
                    :headers {"Content-Type" "text/html"}
                    :body (status)})
  (route/not-found "Page not found"))

当我尝试加载项目时,出现以下错误:
java.lang.Exception: 不支持的绑定形式:(or (serve-file (params :*)) :next) 我做错了什么?我大多数是从互联网上零散的示例中获取的。
在添加空向量后,我得到以下错误:
java.lang.Exception: 无法解析符号:serve-file
1个回答

6

我认为你缺少了绑定表单:

(GET "/*" {params :params} (or (serve-file (params :*)) :next))
        ; ^- note the binding form

2
在最近的Compojure中,我认为应该使用{params:params}而不是一个空向量,因为Compojure不再为您设置魔术params本地变量。 - Brian Carper

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接