servant-static-th-0.2.2.0: Embed a directory of static files in your Servant server

CopyrightDennis Gosnell 2017
LicenseBSD3
MaintainerDennis Gosnell (cdep.illabout@gmail.com)
Stabilityexperimental
Portabilityunknown
Safe HaskellSafe
LanguageHaskell2010

Servant.Static.TH.Internal.FileTree

Description

Read a directory and the contents of all the files in it as a FileTree.

Synopsis

Documentation

data FileTree Source #

This tree structure represents the directory structure on disk.

Constructors

FileTreeFile FilePath ByteString

A file with it's FilePath and contents as a ByteString.

FileTreeDir FilePath (NonEmpty FileTree)

A directory with it's FilePath and the files under it.

data FileType Source #

This is a simple version of FileTree, just used for tagging a given FilePath as a directory or a file.

getFileType :: FilePath -> IO FileType Source #

Get the FileType for a given FilePath. Calls fail if it is not a file or a directory.

fileTypeToFileTree :: FileType -> IO (Maybe FileTree) Source #

Convert a FileType to a FileTree. Return Nothing if the input FileType is FileTypeDir, and that directory is empty.

getFileTree :: FilePath -> IO [FileTree] Source #

Convert an input directory FilePath to a FileTree. Fails if the input directory FilePath is not a directory.

getFileTreeIgnoreEmpty :: FilePath -> IO (NonEmpty FileTree) Source #

Just like getFileTree, but returns an error with fail if the input directory is empty.