npm hono 1.5.0
v1.5.0

latest releases: 4.6.2, 4.6.1, 4.6.0...
2 years ago

BREAKING CHANGES!!

This release includes BREAKING CHANGES.

Routing priority has been changed. The new rules are below:


Handlers or middleware will be executed in registration order.

app.get('/book/a', (c) => c.text('a')) // a
app.get('/book/:slug', (c) => c.text('common')) // common
GET /book/a ---> `a`
GET /book/b ---> `common`

When a handler is executed, the process will be stopped.

app.get('*', (c) => c.text('common')) // common
app.get('/foo', (c) => c.text('foo')) // foo
GET /foo ---> `common` // foo will not be dispatched

If you have the middleware that you want to execute, write the code above the handler.

app.use('*', logger())
app.get('/foo', (c) => c.text('foo'))

If you want a "fallback" handler, write the code below the other handler.

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

What's Changed

  • refactor(reg-exp-router): Routes are returned in the registration order. by @usualoma in #324
  • refactor(trie-router): routes are returned in the registration order by @yusukebe in #325

Full Changelog: v1.4.7...v1.5.0

Don't miss a new hono release

NewReleases is sending notifications on new releases.