mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 04:51:35 +03:00
18 lines
532 B
Haskell
18 lines
532 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")
|