From 4f2a3d4afd816f9b799b3c140f677b45288d74aa Mon Sep 17 00:00:00 2001 From: Alex Mason Date: Wed, 2 Dec 2015 17:50:09 +1100 Subject: [PATCH] Update docspec stuff for Servant.API.Times --- servant/src/Servant/API/Times.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/servant/src/Servant/API/Times.hs b/servant/src/Servant/API/Times.hs index 77979f8c..a3a15b1f 100644 --- a/servant/src/Servant/API/Times.hs +++ b/servant/src/Servant/API/Times.hs @@ -12,11 +12,12 @@ import Data.Typeable (Typeable) import GHC.TypeLits (Symbol) --- | Capture a value from the request path under a certain type @a@. +-- | Capture data/time value from a path in the `format', as understood +-- by 'Data.Time.Format. -- -- Example: --- >>> -- GET /books/:isbn --- >>> type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book +-- >>> -- GET /events/:date +-- >>> type MyApi = "events" :> CaptureTime "date" "%Y-%m-%d" Day :> Get '[JSON] Book data CaptureTime (sym :: Symbol) (format :: Symbol) a deriving (Typeable) @@ -28,3 +29,10 @@ data QueryParamTime (sym :: Symbol) (format :: Symbol) a data QueryParamTimes (sym :: Symbol) (format :: Symbol) a deriving (Typeable) +-- $setup +-- >>> import Servant.API +-- >>> import Data.Aeson +-- >>> import Data.Text +-- >>> import Data.Time.Calendar +-- >>> data Book +-- >>> instance ToJSON Book where { toJSON = undefined }