(file-response filepath)
(file-response filepath options)
Returns a Ring response to serve a static file, or nil if an appropriate
file does not exist.
Options:
:root - take the filepath relative to this root path
:index-files? - look for index.* files in directories (defaults to true)
:allow-symlinks? - allow symlinks that lead to paths outside the root path
(defaults to false)
Source
(defn file-response
"Returns a Ring response to serve a static file, or nil if an appropriate
file does not exist.
Options:
:root - take the filepath relative to this root path
:index-files? - look for index.* files in directories (defaults to true)
:allow-symlinks? - allow symlinks that lead to paths outside the root path
(defaults to false)"
([filepath]
(file-response filepath {}))
([filepath options]
(if-let [file (find-file filepath options)]
(let [data (file-data file)]
(-> (response (:content data))
(content-length (:content-length data))
(last-modified (:last-modified data)))))))