Skip to content

rill-js/redirect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Simple redirect setting middleware for Rill. Supports overriding status with easy defaults.

Installation

npm install @rill/redirect

Example

const app = require('rill')()

// Redirect all "/from" to "/to".
app.get('/from', redirect('/to'))
app.get('/from', redirect('/to', 302))

// Same as.
app.get('/from', ({ res })=> res.redirect('/to'))
app.get('/from', ({ res })=> {
	res.redirect('/to')
	res.status = 302
})

// Will not override existing redirects.
app.get('/from', redirect('/a'))
app.get('/from', redirect('/b')) // b gets skipped.

Contributions

  • Use npm test to run tests.

Please feel free to create a PR!

About

📭 Simple permanent redirect middleware for Rill.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published