(run
(builder
(<clack-middleware-static>
:path "/public/"
:root #p"/static-files/")
app)) This is a Clack Middleware component for serving static files.
path specifies the prefix of URL or a callback to match with requests to serve static files for.
Notice. Don't forget to add slush "/" to the end.
root specifies the root directory to serve static files from.
The following example code would serve /public/foo.jpg from /static-files/foo.jpg.
(run
(builder
(<clack-middleware-static>
:path "/public/"
:root #p"/static-files/")
app)) You can set any function that returns a mapped filename as :path . The above example can be rewritten as following code.
(run
(builder
(<clack-middleware-static>
:path (lambda (path)
(when (ppcre:scan path "^/public/")
(subseq path 7)))
:root #p"/static-files/")
app)) Clack Middleware to intercept requests for static files.