Typed route handlers #1511
armstrong-pv
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
.NET has a feature where you can implement typed route handlers that look like this:
The key part is the method signature which expects a type of Pet in the post. It removes boiler plate response parsing and validation from the controller. Is there any way this can be simulated in Hono? I'd like to specify a generic middleware function backed by the appropriate types to pre-parse the route payload. My typescript isn't good enough to attempt this though! Some of my routes already use middleware, so I'm not even sure whether you can specify multiple middleware functions to the declaration. Here's my user post route as an example I'd like to adapt:
Beta Was this translation helpful? Give feedback.
All reactions