zohl / servant-frontpage

Serving html page from file with caching and detecting changes in the file.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

servant-frontpage

Description

Serving html page from file with caching and detecting changes in the file.

It's a simple wrapper that keeps the page in memory and updates it when necessary.

Example

The following code

type ServerAPI = ... :<|> Get '[HTML] BSL.ByteString

serveAPI :: ServerAPI
serveAPI = ... :<|> (return . BSL.readFile $ "../static/index.html")

can be rewritten like this:

type ServerAPI = ... :<|> FrontPageEndpoint

frontPage <- mkFrontPage "../static/index.html"
let serveAPI = ... :<|> frontPage

See also

About

Serving html page from file with caching and detecting changes in the file.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Haskell 77.7%Language:Nix 22.3%