(file-request request root-path)
(file-request request root-path options)
If request matches a static file, returns it in a response. Otherwise
returns nil. See: wrap-file.
Source
(defn file-request
"If request matches a static file, returns it in a response. Otherwise
returns nil. See: wrap-file."
{:added "1.2"}
([request root-path]
(file-request request root-path {}))
([request root-path options]
(let [options (merge {:root (str root-path)
:index-files? true
:allow-symlinks? false}
options)]
(if (#{:get :head} (:request-method request))
(let [path (subs (codec/url-decode (request/path-info request)) 1)]
(-> (response/file-response path options)
(head/head-response request)))))))