| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Servant.Static.TH.Internal.Api
Documentation
Take a template directory argument as a FilePath and create a Servant
type representing the files in the directory. Empty directories will be
ignored.
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
:<|> "index.html" :> Get '[HTML] Html
Arguments
| :: String | name of the api type synonym |
| -> FilePath | directory name to read files from |
| -> Q [Dec] |
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")