Hoogle Search
Within LTS Haskell 24.69 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
embeddedSettings :: [(FilePath, ByteString)] -> StaticSettingswai-app-static WaiAppStatic.Storage.Embedded Serve the list of path/content pairs directly from memory.
mkSettings :: IO [EmbeddableEntry] -> ExpQwai-app-static WaiAppStatic.Storage.Embedded Create a StaticSettings at compile time that embeds resources directly into the compiled executable. The embedded resources are precompressed (depending on mime type) so that during runtime the resource can be served very quickly. Because of GHC Template Haskell stage restrictions, you must define the entries in a different module than where you create the StaticSettings. For example,
{-# LANGUAGE TemplateHaskell, QuasiQuotes, OverloadedStrings #-} module A (mkEmbedded) where import WaiAppStatic.Storage.Embedded import Crypto.Hash.MD5 (hashlazy) import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Base64 as B64 import qualified Data.Text as T import qualified Data.Text.Encoding as T hash :: BL.ByteString -> T.Text hash = T.take 8 . T.decodeUtf8 . B64.encode . hashlazy mkEmbedded :: IO [EmbeddableEntry] mkEmbedded = do file <- BL.readFile "test.css" let emb = EmbeddableEntry { eLocation = "somedir/test.css" , eMimeType = "text/css" , eContent = Left (hash file, file) } let reload = EmbeddableEntry { eLocation = "anotherdir/test2.txt" , eMimeType = "text/plain" , eContent = Right [| BL.readFile "test2.txt" >>= \c -> return (hash c, c) |] } return [emb, reload]The above mkEmbedded will be executed at compile time. It loads the contents of test.css and computes the hash of test.css for the etag. The content will be available at the URL somedir/test.css. Internally, embedApp below will attempt to compress the content at compile time. The compression will only happen if the compressed content is shorter than the original and the mime type is either text or javascript. If the content is compressed, at runtime the precomputed compressed content will be served with the appropriate HTTP header. If embedApp decides not to compress the content, it will be served directly. Secondly, mkEmbedded creates a reloadable entry. This will be available at the URL anotherdir/test2.txt. Whenver a request comes in for anotherdir/test2.txt, the action inside the quasiquote in eContent will be executed. This will re-read the test2.txt file and recompute its hash. Finally, here is a module which uses the above action to create a Application.{-# LANGUAGE TemplateHaskell #-} module B where import A import Network.Wai (Application) import Network.Wai.Application.Static (staticApp) import WaiAppStatic.Storage.Embedded import Network.Wai.Handler.Warp (run) myApp :: Application myApp = staticApp $(mkSettings mkEmbedded) main :: IO () main = run 3000 myAppdefaultFileServerSettings :: FilePath -> StaticSettingswai-app-static WaiAppStatic.Storage.Filesystem Settings optimized for a file server. More conservative caching will be applied, and indices and listings are enabled.
defaultWebAppSettings :: FilePath -> StaticSettingswai-app-static WaiAppStatic.Storage.Filesystem Settings optimized for a web application. Files will have aggressive caching applied and hashes calculated, and indices and listings are disabled.
webAppSettingsWithLookup :: FilePath -> ETagLookup -> StaticSettingswai-app-static WaiAppStatic.Storage.Filesystem Same as defaultWebAppSettings, but additionally uses a specialized ETagLookup in place of the standard one. This can allow you to cache your hash values, or even precompute them.
-
wai-app-static WaiAppStatic.Types All of the settings available to users for tweaking wai-app-static. Note that you should use the settings type approach for modifying values. See http://www.yesodweb.com/book/settings-types for more information.
-
wai-app-static WaiAppStatic.Types No documentation available.
-
warp-tls Network.Wai.Handler.WarpTLS Determines where to load the certificate, chain certificates, and key from.
-
warp-tls Network.Wai.Handler.WarpTLS Settings for WarpTLS.
defaultTlsSettings :: TLSSettingswarp-tls Network.Wai.Handler.WarpTLS Default TLSSettings. Use this to create TLSSettings with the field record name (aka accessors).