Lucu-0.1: HTTP Daemonic Library

Network.HTTP.Lucu.StaticFile

Description

Handling static files on the filesystem.

Synopsis

Documentation

staticFile :: FilePath -> ResourceDefSource

staticFile fpath is a ResourceDef which serves the file at fpath on the filesystem.

handleStaticFile :: FilePath -> Resource ()Source

Computation of handleStaticFile fpath serves the file at fpath 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

staticDir dir is a ResourceDef which maps all files in dir and its subdirectories on the filesystem to the ResTree.

handleStaticDir :: FilePath -> Resource ()Source

Computation of handleStaticDir dir maps all files in dir 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 generateETagFromFile fpath 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.

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