question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discussion: hono.use

See original GitHub issue

The 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:closed
  • Created a year ago
  • Comments:39 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
usualomacommented, May 10, 2022

I agreed. Please wait a few days.

1reaction
metruecommented, May 10, 2022

@yusukebe @usualoma It’s great we had a very long and meaningful discussion here!!!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found