github honojs/hono v1.4.1

latest releases: v4.3.6, v4.3.5, v4.3.4...
23 months 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.