mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 13:02:11 +03:00
18 lines
584 B
Haskell
18 lines
584 B
Haskell
|
module Data.Parser.Expires
|
||
|
( parseExpirationTime
|
||
|
) where
|
||
|
|
||
|
import Control.Monad.Except
|
||
|
import Data.Text.Conversions
|
||
|
import Data.Time.Clock
|
||
|
import Data.Time.Format (defaultTimeLocale, parseTimeM)
|
||
|
|
||
|
import Hasura.Prelude
|
||
|
|
||
|
|
||
|
-- | Extracts an absolute expiration time from a Expires header.
|
||
|
parseExpirationTime :: MonadError String m => Text -> m UTCTime
|
||
|
parseExpirationTime = fromText
|
||
|
>>> parseTimeM True defaultTimeLocale "%a, %d %b %Y %T GMT"
|
||
|
>>> (`onNothing` throwError "Value of Expires header is not a valid timestamp")
|