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

[Suggestion] Create "Cookie Middleware", obsolete req.cookie() and c.cookie() #965

Closed
yusukebe opened this issue Mar 8, 2023 · 8 comments

Comments

@yusukebe
Copy link
Member

yusukebe commented Mar 8, 2023

For Hono-based applications, there are not many cases in which using cookies. So rather than having c.req.cookie() and c.cookie() as standard, I thought it would be better to provide a method to set and get a cookie.

import { getCookie, setCookie } from 'hono/cookie'

getCookie(c, 'yummy_cookie')
setCookie(c, 'great_cookie', 'banana')

This will reduce the bundle size. This is a good change. However, since it is a breaking change, we must write a migration guide and output a polite error message when a user uses c.req.cookie() or c.cookie().

@yusukebe
Copy link
Member Author

yusukebe commented Mar 8, 2023

I think it may be better to make it "deprecated" at v3 and show the warning messages, and then "obsolete" at v4.

@spiffytech
Copy link

For Hono-based applications, there are not many cases in which using cookies

Just curious why you think this. As a cookie user, I'm not clear on why I'd use cookies less with Hono than with any other tool.

@yusukebe
Copy link
Member Author

What I meant was that using cookies is not as frequent as using 'c.req.query' or 'c.req.param'. Therefore, we decided to make them obsolete because reducing the bundle size is important for Hono.

@spiffytech
Copy link

I hope I'm misunderstanding you saying "obsolete" and that Hono intends to still support cookies (even if from a separate package).

I'm starting to port projects to Hono and I just want to make sure that cookies will still be supported since I get a lot of use out of them 🙂

@yusukebe
Copy link
Member Author

Yes, Hono will continue to support cookies!

@bryiac
Copy link

bryiac commented Jul 23, 2023

I still believe calling this middleware is misleading ~ I feel it would be more appropriate for the cookie and the html middleware to be moved over into another scope/directory such as helpers? honestly name doesn't matter but these even go against the definition of middleware on the hono documentation

@yusukebe

@yusukebe
Copy link
Member Author

@bryiac

Indeed, helpers sounds good.

honestly name doesn't matter but these even go against the definition of middleware on the hono documentation

You have a point. I will consider re-categorizing these, changing their names, or revising the documentation accordingly. Thanks!

@yusukebe
Copy link
Member Author

Fixed by #1934

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants