title: Serving binary files from the database with compojure
body: <p>I have the following routes definition:</p>
  
  <pre><code>(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))))
  </code></pre>
  
  <p>In this example, requesting <code>/</code> works like a charm and returns the expected <code>Hello World 2</code>.</p>
  
  <p>The get-images-response method is defined like this:</p>
  
  <pre><code>(defn get-image-response
    [id]
    (let [record (db/get-image id false)]
      (-&gt; (response/response (:data record))
          (response/content-type (:content-type record))
          (response/header "Content-Length" (:size record)))))
  </code></pre>
  
  <p>I get a 404 though, so the serving of binary files doesn't quite work yet. Any ideas why?</p>
  
  <p>Edit:
  Ok, the issue relates to the fact that images are being requested on <code>/images/name.jpg</code>. As soon as I remove the <code>.jpg</code> the handler gets called. So the question becomes how do I match on anything but the extension?</p>