yesod-static- Static file serving subsite for Yesod Web Framework.




Serve static files from a Yesod app.

This is great for developming your application, but also for a dead-simple deployment. Caching headers are automatically taken care of.

If you are running a proxy server (like Apache or Nginx), you may want to have that server do the static serving instead.

In fact, in an ideal setup you'll serve your static files from a separate domain name to save time on transmitting cookies. In that case, you may wish to use urlRenderOverride to redirect requests to this subsite to a separate domain name.



newtype Static Source


Static StaticSettings 


Yesod master => YesodDispatch Static master 

Smart constructor

static :: FilePath -> IO StaticSource

Default value of Static for a given file folder.

Does not have index files or directory listings. Expects static files to *never* change

staticDevel :: FilePath -> IO StaticSource

like static, but checks to see if the file has changed

embed :: FilePath -> Q ExpSource

Produces a Static based on embedding file contents in the executable at compile time.

Template Haskell helpers

staticFiles :: FilePath -> Q [Dec]Source

This piece of Template Haskell will find all of the files in the given directory and create Haskell identifiers for them. For example, if you have the files "static/style.css" and "static/js/script.js", it will essentailly create:

 style_css = StaticRoute ["style.css"] []
 js_script_js = StaticRoute ["js/script.js"] []

publicFiles :: FilePath -> Q [Dec]Source

like staticFiles, but doesn't append an etag to the query string This will compile faster, but doesn't achieve as great of caching. The browser can avoid downloading the file, but it always needs to send a request with the etag value or the last-modified value to the server to see if its copy is up to dat


base64md5 :: ByteString -> StringSource

md5-hashes the given lazy bytestring and returns the hash as base64url-encoded string.

This function returns the first 8 characters of the hash.