npm hono 1.4.1
v1.4.1

latest releases: 4.6.9, 4.6.8, 4.6.7...
2 years ago

Priority of * is changed

You can write the fallback scenario.

app.get('/page', (c) => c.text('page'))
app.all('*', (c) => c.text('fallback'))
GET /page ---> `page`
GET /foo ---> `fallback`

If / is matched on the top, the middleware will not be dispatched.

app.get('/', (c) => {
  return c.text('foo')
}) // <--- stop process

app.use('*', middleware()) // <--- not dispached!!

If you want to apply middleware in all condition, put it above.

app.use('*', middleware()) // <--- dispached!!

app.get('/', (c) => {
  return c.text('foo')
})

What's Changed

  • refactor(trie-router): make * and /* have same priority by @yusukebe in #274
  • refactor(trie-router): fixed routing priority for * by @yusukebe in #276
  • refactor(reg-exp-router): Update scoring rules in RegExpRouter. by @usualoma in #275
  • refactor: make GraphQL Server middleware as handler by @yusukebe in #277

Full Changelog: v1.4.0...v1.4.1

Don't miss a new hono release

NewReleases is sending notifications on new releases.