Created
March 26, 2018 17:14
-
-
Save Woody88/3d24adabf011f7706d7f0afdecee7cc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Web.Cookie (SetCookie,parseSetCookie,renderSetCookie) | |
-- | | |
-- >>> let Right c = parseUrlPiece "SESSID=r2t5uvjq435r4q7ib3vtdjq120" :: Either Text SetCookie | |
-- >>> toUrlPiece c | |
-- "\"SESSID=r2t5uvjq435r4q7ib3vtdjq120\"" | |
instance ToHttpApiData SetCookie where | |
toUrlPiece = showt . BS.toLazyByteString . renderSetCookie | |
toEncodedUrlPiece = renderSetCookie | |
-- | | |
-- >> parseUrlPiece "SESSID=r2t5uvjq435r4q7ib3vtdjq120" :: Either Text SetCookie | |
-- Right (SetCookie {setCookieName = "SESSID", setCookieValue = "r2t5uvjq435r4q7ib3vtdjq120", setCookiePath = Nothing, setCookieExpires = Nothing, | |
-- setCookieMaxAge = Nothing, setCookieDomain = Nothing, setCookieHttpOnly = False, setCookieSecure = False, setCookieSameSite = Nothing}) | |
instance FromHttpApiData SetCookie where | |
parseUrlPiece = parseHeader . encodeUtf8 | |
parseHeader = Right . parseSetCookie |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment