Moduleservant-static-th-1.0.0.0Haskell2010
Servant.Static.TH.Internal.Api
- 5 values
- Packageservant-static-th-1.0.0.0
- Exports5
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceApi.hs
Take a template directory argument as a FilePath and create a Servant
type representing the files in the directory. Empty directories will be
ignored. index.html files will also be served at the root.
For example, assume the following directory structure:
$ tree dir/
dir/
├── js
│ └── test.js
└── index.html
createApiType is used like the following:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TemplateHaskell #-}
type FrontEndAPI = $(createApiType "dir")
At compile time, it will expand to the following:
type FrontEndAPI =
"js" :> "test.js" :> Get '[JS] ByteString
:<|> Get '[HTML] Html
:<|> "index.html" :> Get '[HTML] Html
value
createApiDec This is similar to createApiType, but it creates the whole type synonym declaration.
Given the following code:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TemplateHaskell #-}
$(createApiDec "FrontAPI" "dir")
You can think of it as expanding to the following:
type FrontAPI = $(createApiType "dir")