-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 cookie management to axum-extra #816
Conversation
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
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.
Instead of having a separate delta type in the API, why not change add
/ remove
to owned-self
methods that return Self
instead of that separate type, and implement IntoResponseParts
for the jars directly?
If the jar types have a must_use
attribute, that should make it equally hard to misuse while making chaining possible and slightly simplifying the API surface. You also wouldn't have to have the jar be a mutable variable then.
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Did you see my overall comment as part of the review?
|
Ah no I missed that somehow. Good idea! |
@jplatte so much nicer now 😃 |
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.
Two more comments:
- The upstream
CookieJar
s have anadd_original
method that only modifies the jar if a cookie of the given name doesn't exist yet. Maybe that should be mirrored? (although the one thing I can immediately think of it being used for would be tracking cookies.. yuck) - Adding an example for this would be nice
Hm not sure. When extracting the jars I call
|
Right. Let's leave it out for now then! |
Hello! |
Hopefully sometimes this month but no guarantees. Take a look at tower-cookies in the mean time. |
I was able to migrate my website to axum using the |
This adds extractors and responses for dealing with cookies to axum-extra. It uses the new
IntoResponseParts
APIs such that no middleware andArc<Mutex<_>>
s are required. This should make things more composable as there is no global "cookie manager" that all changes must go through. It just reads theCookie
header from the request and appendsSet-Cookie
headers to the response.Example usage:
All the heavy lifting is done by the
cookie
crate.