【发布时间】:2011-04-28 15:48:06
【问题描述】:
我有以下路线定义:
(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。
get-images-response 方法定义如下:
(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 binary-data compojure