@rill/unhandled

1.1.0 • Public • Published

Rill
@rill/unhandled
API stability Standard NPM version Downloads Gitter Chat

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.

  1. res.body is undefined.
  2. res.status is 404.
  3. res.get('Location') is undefined.
  4. res.get('Content-Type') is undefined.

Contributions

  • Use npm test to run tests.

Please feel free to create a PR!

Package Sidebar

Install

npm i @rill/unhandled

Weekly Downloads

0

Version

1.1.0

License

MIT

Last publish

Collaborators

  • dylanpiercey