我有以下途径定义:从数据库服务二进制文件用的Compojure
(require '[compojure.core :as ccore]
'[ring.util.response :as response])
(def *main-routes*
(ccore/defroutes avalanche-routes
(ccore/GET "/" [] "Hello World 2")
(ccore/GET "/images/:id" [id] (get-image-response id))))
在这个例子中,请求/
的作品就像一个魅力和返回预期Hello World 2
。
一开始图像响应方法的定义如下:
(defn get-image-response
[id]
(let [record (db/get-image id false)]
(-> (response/response (:data record))
(response/content-type (:content-type record))
(response/header "Content-Length" (:size record)))))
我得到一个404的,所以二进制文件的服务不做得比较工作呢。任何想法为什么?
编辑: 好的,这个问题涉及在/images/name.jpg
上请求图像的事实。一旦我删除.jpg
处理程序被调用。所以问题变成了什么,除了扩展名之外,我该如何匹配?
谢谢您提供的信息,我为您投票,因为它是正确的并与我的问题有关。不幸的是,我真正的问题是clojure-couchdb库中的一个bug,我修补了它。我将在单独的答案中包含所有的细节,以便其他人可以参考它。 – 2010-10-21 20:18:40