Discussion: hono.use
See original GitHub issueThe current handler and middleware design of Hono is great, and I am thinking the possibility to make it a little simpler and cleaner.
- Make the handler and middleware one the same thing, and both apply by
hono.use
const middleware = async (ctx, next) => {
// middleware functionality code
await next()
}
const handler = async (ctx) => {
ctx.body = 'hello world'
}
Then we can apply them with chained style,
new Hono().use(middleware).use(handler)
or compose style,
new Hono().use(middleware, handler)
- Router acts routing responsibility
Hono’s routers (TrieRouter and RegExpRouter) are so cool with high performance as we see in Hono currently, to better support hono.use
mentioned above, we can extend it a little bit to be like,
const router = new TrieRouter()
router
.get('/', (ctx) => ctx.body = 'ok')
.post('/', (ctx) => ctx.body = {'status': 'created'})
...
Then Hono can just apply it likem
hono.use(router.routes())
Does this sound like an idea worth discussing?
Issue Analytics
- State:
- Created a year ago
- Comments:39 (18 by maintainers)
Top Results From Across the Web
Interactive comment on “The role of HONO in O formation and ...
The study describes measurements of HONO and associated atmospheric con- stituents in Seoul during KORUS-AQ. The authors find that elevated ...
Read more >Gas-Phase Nitrous Acid (HONO) Is Controlled by Surface ...
The present study focuses on gas-phase HONO and condensed-phase nitrite and nitrate formation on indoor surface thin films following ...
Read more >Virtual IoT | Eclipse Hono : Connect. Command. Control.
The open source response to closed and proprietary IoT solutions is called Eclipse Hono ! Born out of the collaboration of large companies, ......
Read more >Eclipse Hono
The Eclipse IoT Working Group has therefore discussed a more generic, cloud-based IoT platform architecture which better supports the implementation of IoT ...
Read more >High resolution vertical profiles during NACHTT-11 - OpenSky
Results and Discussion ... are discussed below using the 27–28 February observations ... the use of HONO/NO2 to calculate HONO formation rates at....
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 agreed. Please wait a few days.
@yusukebe @usualoma It’s great we had a very long and meaningful discussion here!!!