Reputation: 1047
I have this Snap site with one top-level location:
snapSite :: Snap ()
snapSite = do
ifTop myHomeHandler
In addition to this, how can I serve static files only if the request path ends with ".css" or ".txt"?
I noticed there is a pathWith
function in Snap.Internal.Core
that could work, but I'm not sure how to fit it into the Snap
monad above.
Upvotes: 1
Views: 143
Reputation: 66857
"Snap.Util.FileServe [c]ontains web handlers to serve files from a directory."
The route will look something like this:
("/static", serveDirectory "static_directory_name")
For fine-tuning this process you can also use your own DirectoryConfig
and use serveDirectoryWith
.
Upvotes: 1