juxt / bidi

Bidirectional URI routing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

resourcesMaybe no caching

awb99 opened this issue · comments

commented

the handler for files is wrapped with (wrap-not-modified).

the resource handler does not have this middleware call.
It is not logical that one has, and the other has not.

I propose to ad it to the resource handler.

commented

this is how resourcesmaybe should be written:

(defrecord ResourcesMaybe [options]
   bidi/Matched
   (resolve-handler [this m]
     (let [path (url-decode (:remainder m))]
       (when (not-empty path)
         (when-let [res (io/resource (str (:prefix options) path))]
           (assoc (dissoc m :remainder)
                  :handler (->
                            (fn [req] (resource-response (str (:prefix options) path)))
                            (wrap-content-type options)
                            (wrap-not-modified) ; awb99 hack
                            ))))))
   (unresolve-handler [this m]
     (when (= this (:handler m)) "")))