Open awb99 opened 3 years ago
filesmaybe is useful as well. I modelled it after resourcesMaybe
(defrecord FilesMaybe [options] bidi/Matched (resolve-handler [this m] (let [reminder (url-decode (:remainder m)) filename (str (:dir options) reminder)] ;(warn "file-maybe: " filename) (when (.exists (io/file filename)) ;(warn "file found: " filename) (assoc (dissoc m :remainder) :handler (-> (fn [req] (file-response reminder {:root (:dir options)})) (wrap-content-type options) (wrap-not-modified)))))) (unresolve-handler [this m] (when (= this (:handler m)) "")))
filesmaybe is useful as well. I modelled it after resourcesMaybe