Safe Haskell | None |
---|
Static file serving for WAI.
- staticApp :: StaticSettings -> Application
- defaultWebAppSettings :: StaticSettings
- webAppSettingsWithLookup :: FilePath -> ETagLookup -> StaticSettings
- defaultFileServerSettings :: StaticSettings
- data StaticSettings
- ssFolder :: StaticSettings -> Pieces -> IO FileLookup
- ssMkRedirect :: StaticSettings -> Pieces -> ByteString -> ByteString
- ssGetMimeType :: StaticSettings -> File -> IO MimeType
- ssListing :: StaticSettings -> Maybe Listing
- ssIndices :: StaticSettings -> [Text]
- ssMaxAge :: StaticSettings -> MaxAge
- ssRedirectToIndex :: StaticSettings -> Bool
- type MimeType = ByteString
- defaultMimeType :: MimeType
- type Extension = FilePath
- type MimeMap = Map Extension MimeType
- takeExtensions :: FilePath -> [FilePath]
- defaultMimeTypes :: MimeMap
- mimeTypeByExt :: MimeMap -> MimeType -> FilePath -> MimeType
- defaultMimeTypeByExt :: FilePath -> MimeType
- type Pieces = [FilePath]
- pathFromPieces :: FilePath -> Pieces -> FilePath
- type Listing = Pieces -> Folder -> IO ByteString
- defaultListing :: Listing
- fileSystemLookup :: FilePath -> Pieces -> IO FileLookup
- fileSystemLookupHash :: ETagLookup -> FilePath -> Pieces -> IO FileLookup
- embeddedLookup :: Embedded -> Pieces -> IO FileLookup
- type Embedded = Map FilePath EmbeddedEntry
- data EmbeddedEntry
- toEmbedded :: [(FilePath, ByteString)] -> Embedded
- defaultMkRedirect :: Pieces -> ByteString -> ByteString
- data File = File {
- fileGetSize :: Int
- fileToResponse :: Status -> ResponseHeaders -> Response
- fileName :: FilePath
- fileGetHash :: IO (Maybe ByteString)
- fileGetModified :: Maybe EpochTime
- newtype FilePath = FilePath {
- unFilePath :: Text
- toFilePath :: FilePath -> FilePath
- fromFilePath :: FilePath -> FilePath
- data MaxAge
- type ETagLookup = FilePath -> IO (Maybe ByteString)
WAI application
Settings
data StaticSettings Source
ssFolder :: StaticSettings -> Pieces -> IO FileLookupSource
ssMkRedirect :: StaticSettings -> Pieces -> ByteString -> ByteStringSource
ssGetMimeType :: StaticSettings -> File -> IO MimeTypeSource
ssIndices :: StaticSettings -> [Text]Source
Generic, non-WAI code
Mime types
type MimeType = ByteStringSource
Mime type by file extension
takeExtensions :: FilePath -> [FilePath]Source
A list of all possible extensions, starting from the largest.
Finding files
pathFromPieces :: FilePath -> Pieces -> FilePathSource
Directory listings
type Listing = Pieces -> Folder -> IO ByteStringSource
Lookup functions
fileSystemLookup :: FilePath -> Pieces -> IO FileLookupSource
fileSystemLookupHash :: ETagLookup -> FilePath -> Pieces -> IO FileLookupSource
embeddedLookup :: Embedded -> Pieces -> IO FileLookupSource
Embedded
type Embedded = Map FilePath EmbeddedEntrySource
toEmbedded :: [(FilePath, ByteString)] -> EmbeddedSource
Redirecting
Other data types
File | |
|
toFilePath :: FilePath -> FilePathSource
System.Directory functions are a lie: they claim to be using String, but it's really just a raw byte sequence. We're assuming that non-Windows systems use UTF-8 encoding (there was a discussion regarding this, it wasn't an arbitrary decision). So we need to encodedecode the byte sequence tofrom UTF8. That's the use case for fixPathName/unfixPathName. I'm starting to use John Millikin's system-filepath package for some stuff with work, and might consider migrating over to it for this in the future.
type ETagLookup = FilePath -> IO (Maybe ByteString)Source