Clack.Middleware.Static - Middleware to serve static files.

SYNOPSIS

(run  
  (builder  
   (<clack-middleware-static>  
    :path "/public/"  
    :root #p"/static-files/")  
   app)) 

DESCRIPTION

This is a Clack Middleware component for serving static files.

Slots

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.

EXAMPLE

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)) 

AUTHOR

SEE ALSO

EXTERNAL SYMBOLS