Copyright | (c) 2014 Andreas Meingast <ameingast@gmail.com> |
---|---|
License | BSD-style |
Maintainer | ameingast@gmail.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell98 |
WAI ETag middleware for static files.
- etag :: Bool -> MaxAge -> Middleware
- etag' :: ETagContext -> MaxAge -> Middleware
- respond :: Monad m => MaxAge -> Response -> [Header] -> m Response
- addCacheControl :: MaxAge -> Response -> Response
- modifiedSince :: Request -> Maybe HTTPDate
- hashFileCached :: ETagContext -> FilePath -> IO HashResult
- cacheControl :: MaxAge -> ResponseHeaders -> ResponseHeaders
- hashFile :: FilePath -> IO HashResult
- getModificationTimeIfExists :: FilePath -> IO (Maybe EpochTime)
- data MaxAge
- data HashResult
- data ETagContext = ETagContext {
- etagCtxUseCache :: !Bool
- etagCtxCache :: !(MVar (HashMap FilePath ByteString))
Documentation
etag :: Bool -> MaxAge -> Middleware Source
Attaches the middleware. Enable caching if the first argument is True
.
etag' :: ETagContext -> MaxAge -> Middleware Source
Attaches the middleware with a provided context.
respond :: Monad m => MaxAge -> Response -> [Header] -> m Response Source
Finalize the response by attaching a cache-control header based on age.
addCacheControl :: MaxAge -> Response -> Response Source
Add cache control headers to the response object.
modifiedSince :: Request -> Maybe HTTPDate Source
Determine if-modified-since tag from the http request if present.
hashFileCached :: ETagContext -> FilePath -> IO HashResult Source
Determine the hash of a provided file located at path
.
If caching is enabled, use the cached checksum, otherwise
always re-calculate.
cacheControl :: MaxAge -> ResponseHeaders -> ResponseHeaders Source
Add cache-control to the provided response-headears.
hashFile :: FilePath -> IO HashResult Source
Hash the file with MD5 located at fp
.
getModificationTimeIfExists :: FilePath -> IO (Maybe EpochTime) Source
Determine the file modification time at the location fp
if it exists.
Maximum age that will be attached to all file-resources processed by the middleware.
data HashResult Source
The result of an hash-calculation of a file.
data ETagContext Source
The configuration context of the middleware.
ETagContext | |
|