Summary
There are three new features. All of them are useful to you.
1. c.runtime
You can know which runtime the code is running on with c.runtime
. This is implemented by @yujong-lee. Thanks!
app.get('/which-runtime/*', (c) => {
return c.text(`You are on ${c.runtime}!`)
})
2. app.showRoutes()
The app.showRoutes()
shows the routes which are registered.
3. app.on()
The app.on()
function will enable us set the custom HTTP method as we like:
app.on('PURGE', '/foo', async (c) => {
await purgeCache('foo')
return c.redirect('/')
})
What's Changed
- feat(context): Introducing c.runtime by @yujong-lee in #644
- fix(type): make compatibility with
@cloudflare/workers-types
by @yusukebe in #645 - refactor(types): reduce type definitions by @yusukebe in #649
- fix(context): check cloudflare before checking node in
c.runtime
by @yusukebe in #651 - fix(error): make
notFound()
enables to catch errors correctly by @yusukebe in #652 - feat(app): introduce
app.showRoutes()
by @yusukebe in #650 - feat(app): introduce
app.on(method, path, handler)
by @yusukebe in #653 - fix(types): export
ErrorHandler
andNotFoundHandler
by @yusukebe in #656
Full Changelog: v2.4.1...v2.5.0