我有以下路线定义:
(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
处理程序就会被调用。所以问题变成了我如何匹配除了扩展名之外的任何东西?