@rill/unhandled
v1.1.0
Published
Build Rill middleware that only run on unhandled requests.
Downloads
4
Maintainers
Readme
Utility to create Rill middleware that only runs on unhandled requests.
Installation
npm install @rill/unhandled
Example
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))
Details
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
.
Contributions
- Use
npm test
to run tests.
Please feel free to create a PR!