How to properly access request param types in handlers where params are documented in parent router? #2299
cainenielsen
started this conversation in
General
Replies: 2 comments
-
Ah, I just found a question I believe is similar. |
Beta Was this translation helpful? Give feedback.
0 replies
-
It is not a bug, nor one we do not plan to address at this time right now. However, it is good to leave it as a feature request while it will be difficult to implement. The workaround is this: childrouter.get('/some-path', async (context) => {
const someId = context.req.param<'/:someId'>('someId')
return context.text(someId)
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am pretty new to Hono so I am assuming I am missing something obvious, but I have exhausted the content on hono.dev trying to understand this so here we go.
My goal is to follow the recommendation of using nested
Hono()
instances for grouping routes and to support custom parameters in paths; eg./:someId
, which seems to work for handlers set directly on hono instances withbasePath()
but not on handlers set on child instances using.route()
. I assume the context of the request parameter and its type is losted between the two instances.My questions are as follows...
Example:
Thanks for your time and support.
Beta Was this translation helpful? Give feedback.
All reactions