safe-routes-match

1.0.0 • Public • Published

safe-routes-match

A simple module to 404 when there isn't a match for a route.

usage

From your initial request handler:

var http = require('http')
var url = require('url')
var safe_match = require('safe-routes-match')
var router = require('./lib/router')

http.createServer(function (req, res) {
  var path = url.parse(req.url).pathname
  var match = router.match(path)
  safe_match(req, res, match)
})

If you are doing the .next() thing:

function myRoute (req, res, match) {
  // Do interesting middleware-y stuff
  match = match.next()
  safe_match(req, res, match)
}

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i safe-routes-match

      Weekly Downloads

      2

      Version

      1.0.0

      License

      MIT

      Last publish

      Collaborators

      • wraithan