Utility to create Rill middleware that only runs on unhandled requests.
npm install @rill/unhandled
const app = require('rill')()
const redirect = require('@rill/redirect')
const unhandled = require('@rill/unhandled')
// Redirect to 404 when page is unhandled.
app.get(unhandled(redirect('/404')))
// Example routes.
app.get('/home', render(homePage))
app.get('/404', render(notFoungPage))
The middleware provided to unhandled
will only be invoked when the following conditions are met.
res.body
isundefined
.res.status
is404
.res.get('Location')
isundefined
.res.get('Content-Type')
isundefined
.
- Use
npm test
to run tests.
Please feel free to create a PR!