(wrap-file handler root-path)
(wrap-file handler root-path options)
Wrap an handler such that the directory at the given root-path is checked for
a static file with which to respond to the request, proxying the request to
the wrapped handler if such a file does not exist.
Accepts the following options:
:index-files? - look for index.* files in directories, defaults to true
:allow-symlinks? - serve files through symbolic links, defaults to false
Source
(defn wrap-file
"Wrap an handler such that the directory at the given root-path is checked for
a static file with which to respond to the request, proxying the request to
the wrapped handler if such a file does not exist.
Accepts the following options:
:index-files? - look for index.* files in directories, defaults to true
:allow-symlinks? - serve files through symbolic links, defaults to false"
([handler root-path]
(wrap-file handler root-path {}))
([handler root-path options]
(ensure-dir root-path)
(fn
([request]
(or (file-request request root-path options) (handler request)))
([request respond raise]
(if-let [response (file-request request root-path options)]
(respond response)
(handler request respond raise))))))