Skip to content

🕵️‍♀️ Build Rill middleware that only run on unhandled requests.

Notifications You must be signed in to change notification settings

rill-js/unhandled

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

🕵️‍♀️ Build Rill middleware that only run on unhandled requests.

Resources

Stars

Watchers

Forks

Packages

No packages published