| Copyright | Dennis Gosnell 2017 |
|---|---|
| License | BSD3 |
| Maintainer | Dennis Gosnell (cdep.illabout@gmail.com) |
| Stability | experimental |
| Portability | unknown |
| Safe Haskell | None |
| Language | Haskell2010 |
Servant.RawM.Internal.Server
Contents
Description
- serveDirectoryWebApp :: Applicative m => FilePath -> ServerT (RawM' serverType) m
- serveDirectoryFileServer :: Applicative m => FilePath -> ServerT (RawM' serverType) m
- serveDirectoryWebAppLookup :: Applicative m => ETagLookup -> FilePath -> ServerT (RawM' serverType) m
- serveDirectoryEmbedded :: Applicative m => [(FilePath, ByteString)] -> ServerT (RawM' serverType) m
- serveDirectoryWith :: Applicative m => StaticSettings -> ServerT (RawM' serverType) m
Documentation
serveDirectoryWebApp :: Applicative m => FilePath -> ServerT (RawM' serverType) m Source #
Serve anything under the specified directory as a RawM' endpoint.
type MyApi = "static" :> RawM' server :: ServerT MyApi m server = serveDirectoryWebApp "/var/www"
would capture any request to /static/<something> and look for
<something> under /var/www.
It will do its best to guess the MIME type for that file, based on the extension, and send an appropriate Content-Type header if possible.
If your goal is to serve HTML, CSS and Javascript files that use the rest of the API
as a webapp backend, you will most likely not want the static files to be hidden
behind a /static/ prefix. In that case, remember to put the serveDirectoryWebApp
handler in the last position, because servant will try to match the handlers
in order.
Corresponds to the defaultWebAppSettings StaticSettings value.
serveDirectoryFileServer :: Applicative m => FilePath -> ServerT (RawM' serverType) m Source #
Same as serveDirectoryWebApp, but uses defaultFileServerSettings.
serveDirectoryWebAppLookup :: Applicative m => ETagLookup -> FilePath -> ServerT (RawM' serverType) m Source #
Same as serveDirectoryWebApp, but uses webAppSettingsWithLookup.
serveDirectoryEmbedded :: Applicative m => [(FilePath, ByteString)] -> ServerT (RawM' serverType) m Source #
Uses embeddedSettings.
serveDirectoryWith :: Applicative m => StaticSettings -> ServerT (RawM' serverType) m Source #
Alias for staticApp. Lets you serve a directory with arbitrary
StaticSettings. Useful when you want particular settings not covered by
the four other variants. This is the most flexible method.