-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Base64 get/setCookie and documentation to Obelisk.Frontend.Cookie #1017
base: develop
Are you sure you want to change the base?
Add Base64 get/setCookie and documentation to Obelisk.Frontend.Cookie #1017
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just tiny requests
@@ -10,26 +10,72 @@ | |||
{-# LANGUAGE RankNTypes #-} | |||
{-# LANGUAGE TypeFamilies #-} | |||
{-# LANGUAGE UndecidableInstances #-} | |||
{-# LANGUAGE OverloadedStrings #-} | |||
{-| | |||
Description: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation 💜
|
||
|
||
|
||
-- TODO: Make generic over both frontend and backend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo in code >:|
can you make an issue instead?
askCookies = fmap (parseCookies . encodeUtf8) $ DOM.getCookie =<< askDocument | ||
|
||
-- | Store a cookie which will be Base64 encoded. | ||
setCookie :: (HasSetCookie m) => SetCookie -> m () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name this encodeAndSetCookie
? I don't want it to be surprising that this function re-encodes your cookie value for you.
This extends the Cookie module with a class for setting cookies and adds some documentation to the module.
HasSetCookie
is implemented onSnap
andMonadJSM/Client m
. The Haddocks warn thatHasSetCookie
andHasCookies
do not necessarily implement a state monad. While this is the case forClient m
, inSnap
setting cookies affects the HTTP response while asking cookies looks at the request. I did this for pragmatic reasons (not breaking old code, not requiring a wrapper type inside Snap to distinguish the two sources of cookies).A few helper functions are added to encourage Base64 use by default:
setCookie
andaskCookie
work do Base64 encoding/decoding of cookies.develop
branchhlint .
(lint found code you did not write can be left alone)$(nix-build -A selftest --no-out-link)
Failed on some unrelated points?nix-build release.nix -A build.x86_64-linux --no-out-link
(orx86_64-darwin
on macOS)Closes #977.