2015-02-24 10:28:23 +01:00
|
|
|
{-# LANGUAGE DataKinds #-}
|
|
|
|
{-# LANGUAGE DeriveDataTypeable #-}
|
|
|
|
{-# LANGUAGE PolyKinds #-}
|
2014-11-22 15:55:50 +01:00
|
|
|
module Servant.API.Capture (Capture) where
|
2014-10-25 01:27:39 +02:00
|
|
|
|
2015-02-24 10:28:23 +01:00
|
|
|
import Data.Typeable (Typeable)
|
|
|
|
import GHC.TypeLits (Symbol)
|
2014-11-22 15:55:50 +01:00
|
|
|
-- | Capture a value from the request path under a certain type @a@.
|
|
|
|
--
|
|
|
|
-- Example:
|
2015-02-24 10:28:23 +01:00
|
|
|
-- >>> -- GET /books/:isbn
|
|
|
|
-- >>> type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book
|
|
|
|
data Capture (sym :: Symbol) a
|
|
|
|
deriving (Typeable)
|
|
|
|
|
|
|
|
-- $setup
|
|
|
|
-- >>> import Servant.API
|
|
|
|
-- >>> import Data.Aeson
|
|
|
|
-- >>> import Data.Text
|
|
|
|
-- >>> data Book
|
|
|
|
-- >>> instance ToJSON Book where { toJSON = undefined }
|