Handling static files on the filesystem.
- staticFile :: FilePath -> ResourceDef
- handleStaticFile :: FilePath -> Resource ()
- staticDir :: FilePath -> ResourceDef
- handleStaticDir :: FilePath -> Resource ()
- generateETagFromFile :: FilePath -> IO ETag
Documentation
staticFile :: FilePath -> ResourceDefSource
is a
staticFile
fpathResourceDef
which serves the file
at fpath
on the filesystem.
handleStaticFile :: FilePath -> Resource ()Source
Computation of
serves the file at
handleStaticFile
fpathfpath
on the filesystem. The
Resource
must be in the /Examining
Request state before the computation. It will be in the Done/
state after the computation.
If you just want to place a static file on the
ResTree
, you had better use
staticFile
instead of this.
staticDir :: FilePath -> ResourceDefSource
is a
staticDir
dirResourceDef
which maps all files
in dir
and its subdirectories on the filesystem to the
ResTree
.
handleStaticDir :: FilePath -> Resource ()Source
Computation of
maps all files in handleStaticDir
dirdir
and its subdirectories on the filesystem to the
ResTree
. The
Resource
must be in the /Examining
Request state before the computation. It will be in the Done/
state after the computation.
If you just want to place a static directory tree on the
ResTree
, you had better use
staticDir
instead of this.
generateETagFromFile :: FilePath -> IO ETagSource
Computation of
generates a strong
entity tag from a file. The file doesn't necessarily have to be a
regular file; it may be a FIFO or a device file. The tag is made of
inode ID, size and modification time.
generateETagFromFile
fpath
Note that the tag is not strictly strong because the file could be modified twice at a second without changing inode ID or size, but it's not really possible to generate a strict strong ETag from a file since we don't want to simply grab the entire file and use it as an ETag. It is indeed possible to hash it with SHA-1 or MD5 to increase strictness, but it's too inefficient if the file is really large (say, 1 TiB).