2010-10-08 62 views
4

我有一個小的Compojure網站,與路線定義爲這樣:的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: Unsupported binding form: (or (serve-file (params :*)) :next)

我是什麼做錯了?我從互聯網上的大量例子中分離出來。

加入空載體後,我得到這個錯誤:
java.lang.Exception: Unable to resolve symbol: serve-file in this context

回答

6

我認爲你缺少約束力的形式:

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

在最近的Compojure我覺得應該是'{PARAMS: params}'而不是空矢量,因爲Compojure不再爲你設置本地的魔術'params'。 – 2010-10-08 19:00:03

+0

@Brian Carper:哦,沒錯。固定。謝謝! – 2010-10-11 16:22:35