Skip to content
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

feat(cookieJar): Change cookie.get to directly return value #10493

Merged
merged 5 commits into from
Apr 22, 2024

Conversation

dac09
Copy link
Collaborator

@dac09 dac09 commented Apr 21, 2024

Motivation
My original design of the CookeiJar.get would return the full cookie object we store, including cookie options. This is not ideal because you need to access the cookie like this:

const myCookie = mwRequest.cookies.get('myCookie')

// 👇
const actualValue = myCookie.value

This is unwieldy, and feels unergonomic for the 98% of cases where get will be used to just see the value.

How do I still see the options of the cookie?
You can still access all the details of the cookie by doing cookie.entries. I don't really have a case for this yet, so let's not optimise for this case, but we know it's possible!

This is me just stabilizing the API for Middleware stuff, before we ship it out of experimental

@dac09 dac09 added the release:feature This PR introduces a new feature label Apr 21, 2024
@dac09 dac09 added this to the SSR milestone Apr 21, 2024
@dac09 dac09 requested a review from Tobbe April 21, 2024 09:37
Copy link
Member

@Tobbe Tobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can still access all the details of the cookie by doing cookie.entries. I don't really have a case for this yet, so let's not optimise for this case, but we know it's possible!

I agree. Let's not add anything for this for now. But if we wanted, in the future, we could add something like getObject, getFullCookie, getCookieWithOptions or whatever name we agree on.

@dac09 dac09 enabled auto-merge (squash) April 22, 2024 16:35
@dac09 dac09 merged commit c6788cd into redwoodjs:main Apr 22, 2024
46 checks passed
dac09 added a commit that referenced this pull request Apr 23, 2024
…g-gen-mw-p2

* 'main' of github.com:redwoodjs/redwood:
  feat(server-auth): WebAuthN support during SSR (#10498)
  Removes old HTML comments from CLI commands doc
  feat(cookieJar): Change cookie.get to directly return value (#10493)
@Josh-Walker-GM Josh-Walker-GM modified the milestones: SSR, v8.0.0 Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:feature This PR introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants