servant-static-th- Embed a directory of static files in your Servant server

Safe HaskellNone




combineWithServantOrT :: NonEmpty (Q Type) -> Q Type Source #

Given a list of Q Type, combine them with Servant's '(:|)' function and return the resulting Q Type.

createApiType Source #


:: FilePath

directory name to read files from

-> Q Type 

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/
  ├── 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

createApiDec Source #


:: 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")