Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filesmaybe missing #209

Open
awb99 opened this issue Jun 1, 2021 · 0 comments
Open

filesmaybe missing #209

awb99 opened this issue Jun 1, 2021 · 0 comments

Comments

@awb99
Copy link

awb99 commented Jun 1, 2021

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)) "")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant