-
-
Notifications
You must be signed in to change notification settings - Fork 129
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: make context available to middleware #934
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
throw new Error('Cannot rerender'); | ||
}, | ||
}; | ||
await runWithRenderStoreInternal(renderStore, () => run(0)); |
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 doesn't looks nice. This function shouldn't be used outside RSC capabilities.
Consider unstable_getHonoContext
is for server components.
Middleware can use __hono_context
directly.
A little concern of mine is there can be two types of middleware, one that depends on hono and the other that doesn't.
not planned for now. |
(but this brings me back to possibly prefer or change "render storage" to "request storage" 🤔 . Not anytime soon. |
Yes, no problem. As I work on my apps, I will look for ways to replace any specific use of Hono with the Waku context. I actually am seeing less and less of a need for it now that I understand Waku better. We could just make the Cloudflare bindings accessible on the Waku context instead of Hono.
Haha... Not anytime soon sounds good. I'm ready to move onto other things. 😃 But... moving c.env/c.executionCtx to ctx.context.cloudflareEnv / ctx.context.executionCtx for the Cloudflare Pages build might be worthwhile. Then I could avoid mentioning Hono so much in the Cloudflare guide. |
The reason I mark getCustomContext and getHonoContext Naming is hard. Hono's middleware and Waku's middleware, and Hono's context and Waku's context. |
One thing to note here, if we call the same function (like a data fetcher) that needs something from context, then it is necessary to pass through the context when calling it from waku middleware but use |
Re: #914 I noticed I had to use
ctx.context.__hono_context
to access the hono context from middleware. While that is ok, I thought it might be useful to try to make thectx.context
available to middleware from theunstable_getCustomContext
API.