diff --git a/servant/servant.cabal b/servant/servant.cabal index 854e499b..8cac1e7e 100644 --- a/servant/servant.cabal +++ b/servant/servant.cabal @@ -42,6 +42,7 @@ library Servant.API.ReqBody Servant.API.ResponseHeaders Servant.API.Sub + Servant.API.Times Servant.API.Vault Servant.Utils.Links build-depends: diff --git a/servant/src/Servant/API.hs b/servant/src/Servant/API.hs index 2e6abb2a..635c8b1d 100644 --- a/servant/src/Servant/API.hs +++ b/servant/src/Servant/API.hs @@ -23,6 +23,10 @@ module Servant.API ( -- | Is the request made through HTTPS? module Servant.API.Vault, -- | Access the location for arbitrary data to be shared by applications and middleware + module Servant.API.Times, + -- | Capturing dates and times in URLs and params with specified formats. + + -- * Actual endpoints, distinguished by HTTP method module Servant.API.Get, @@ -83,6 +87,7 @@ import Servant.API.ResponseHeaders (AddHeader (addHeader), HList (..), Headers (..), getHeadersHList, getResponse) import Servant.API.Sub ((:>)) +import Servant.API.Times (CaptureTime, QueryParamTime, QueryParamTimes) import Servant.API.Vault (Vault) import Web.HttpApiData (FromHttpApiData (..), ToHttpApiData (..)) import Servant.Utils.Links (HasLink (..), IsElem, IsElem', diff --git a/servant/src/Servant/API/Times.hs b/servant/src/Servant/API/Times.hs new file mode 100644 index 00000000..77979f8c --- /dev/null +++ b/servant/src/Servant/API/Times.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module Servant.API.Times where + +import Data.Typeable (Typeable) +import GHC.TypeLits (Symbol) + + +-- | Capture a value from the request path under a certain type @a@. +-- +-- Example: +-- >>> -- GET /books/:isbn +-- >>> type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book +data CaptureTime (sym :: Symbol) (format :: Symbol) a + deriving (Typeable) + + +data QueryParamTime (sym :: Symbol) (format :: Symbol) a + deriving (Typeable) + + +data QueryParamTimes (sym :: Symbol) (format :: Symbol) a + deriving (Typeable) +