bidi icon indicating copy to clipboard operation
bidi copied to clipboard

resourcesMaybe no caching

Open awb99 opened this issue 4 years ago • 1 comments

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.

awb99 avatar May 11 '21 04:05 awb99

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)) "")))

awb99 avatar May 11 '21 15:05 awb99