Extending Context
See original GitHub issueThere is a request to extend Context. Discussed at #410 and https://github.com/honojs/honojs.dev/pull/1
The possibility of adding c.afunction()
by the middleware is a good feature, I think.
But I don’t have any idea to implement it. One idea is using declare module
:
declare module 'hono' {
interface Context {
afunction()
}
}
It seems to be not smart. Is there someone have other ideas?
Issue Analytics
- State:
- Created a year ago
- Comments:16 (4 by maintainers)
Top Results From Across the Web
Extend Context - Cortex XSOAR
You can extend context either in a playbook task, or directly from the command line. Whichever method you use, Cortex XSOAR recommends that...
Read more >Extending context data returned by the Layout Service
Options for customizing the Sitecore context data. ... Extending context data returned by the Layout Service. Current version: 19.0.
Read more >context extension in nLab
In dependent type theory, context extension introduces new free variables into the context. 2. Definition. If T is a type in a context...
Read more >How to extend Context? #209 - oakserver/oak - GitHub
Now, I want to add some attributes to context,Whenever I want to return a JSON data, I need to write it ctx.response.body So...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would like this ability, but mostly because I would like to add something like a
ctx.auth()
orctx.trace()
.That said, I’m fine creating a helper like
getAuth(ctx)
orgetTrace(ctx)
that usesget/set
under the covers.Hi @usualoma !
Agree. I think it would be easier for users to understand if there is an explicit method. So, the author of the middleware should provide a method like “validatoResult” if wants to get some values from Context.
Though we have this guideline, feature #429 is good for us. I’ll merge it.