-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
cookie.Manager and DefaultManager #8
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 5 +4
Lines 146 189 +43
=========================================
+ Hits 146 189 +43 ☔ View full report in Codecov by Sentry. |
I appreciate you consider this rewriting |
@ccoVeille We'll see how the experiment goes, but I'm certainly willing to entertain it for now. I've finished my initial pass of just the Cookie Would love any feedback from the first pass. |
It seems to me that providing the I'll leave this open for feedback while I sleep and check back in, and maybe we can get this merged in if I don't come up with any reasons not to between now and then. |
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.
Small remark about README, except that 👍
import "net/http" | ||
|
||
// DefaultManager is the default cookie manager exposed by this package. | ||
var DefaultManager = NewManager() |
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.
I don't think this one has to be exported
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.
This way it's overrideable, so if you want to set custom functions or a custom signing key you can set the value
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.
Usage of this is documented in the README
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.
OK, please let me check one more thing
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.
OK, I was a bit afraid the DefaultManager would be altered by one of the Manager methods.
It seems OK.
There is no such a thing as:
- get the default
- set something that could alter the default
- any code relying on same lib, would have an altered default
The only way to alter it is via the NewManager. So it's fine.
Maybe a test could cover that no matter how many calls you do to public method, defaultmanager is untouched.
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.
I'm not totally sure what you mean, it's perfectly okay for the user of the library to touch the DefaultManager
if they wish to override it with specific settings.
I'll update the example to showcase the intent of this.
@ccoVeille I'm pretty solid with getting this merged in pending the |
I'm sorry if it wasn't clear. I was worried the DefaultManager could be affected in some way. Something like cookie.DefaultManager.Set(whatever) that would affect the cookie.DefaultManager I checked and I see nothing that could lead to that with current code. The only thing that can alter a manager is when you create it with NewManager and pass Option. But once created, you cannot alter it. So it's immutable, so it's perfect. I hope it's clearer, if not never mind, you can merge anyway. |
Based on some changes in the latest version, as well as some optimizations I think we're able to do to the package overall, this changeset contains the following major changes:
cookie.Manager
is now the primary API to the packagecookie.DefaultManager
is initialized and provides API stability for the globalSet/Get/...
methods.cookie.NewManager(cookie.WithSigningKey(signingKey))
CustomTypeHandler
so we no longer impose a specific dependency (gofrs/uuid)PopulateFromCookies
functionalityDefaultOptions
- ThemergeOptions
functionality wasn't working well anyways.omitempty
to silently ignore missing cookies.While I hope this introduces the least amount of API breakage as possible, I hope the new API will be significantly more stable than the previous iterations and this can be the foundation for moving forward.