-
Notifications
You must be signed in to change notification settings - Fork 11
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
docs: Add example of using AsyncLocalStorage to README #47
docs: Add example of using AsyncLocalStorage to README #47
Conversation
Hi @chimame Looks good! But have you ever tried the Context Storage Middleware? I've never tried it, but it will work. If so, this middleware will be suitable for this use-case instead of using |
Thank you for checking. I changed it to a usage example that uses Context Storage Middleware. I confirmed that the code I wrote actually works. |
README.md
Outdated
import { getContext } from 'hono/context-storage' // It can be called anywhere for server-side processing. | ||
|
||
export const loader = () => { | ||
const cookie = getContext<Env>().headers.get('Cookie') |
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 just curious. Is it difficult to get a Header
object in loader
without this way using AsyncLocalStorage
?
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.
It's very simple.
export const loader = ({ request }: LoaderFunctionArg) => {
const cookie = request.headers.get('Cookie')
}
Remix can be retrieved easily like this. Originally, I wanted to write it in the server processing function called from loader
rather than in loader
, but I was worried that doing so would increase the amount of sample program description in the README.
Shall I write it in an easy-to-understand way?
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.
LGTM!
Thanks, @chimame ! Looks good. I'll merge this now. |
Thanks for the great library.
Using this library has made Remix even easier to use.
I realized that I could use AsyncLocalStorage, so I added an example of how to use it to the README.
If you don't mind the usage method, why not add it?