Module: skyring/lib/server/route

represents the middleware stack for a url / method combination


new (require("skyring/lib/server/route"))(path, method)

Parameters:
Name Type Description
path String

the url pattern to match

method String

The http method to respect

Source:
Example
var rte = new Route('/foo/:id', 'POST')
rte.use((req, res, node, next) => {
  if(req.method === 'DELETE') {
    const err = new Error('Not Implemented')
    err.statusCode = 501
    next(err)
  }
})

Requires

  • module:path-to-regexp

Methods


before(fn)

Adds a middleware function to the beginning of the internal route stack

Parameters:
Name Type Description
fn module:skyring/lib/server/route~Middleware

a the middelware function to add

Source:

use(fn)

Adds a middleware function to the end of the internal route stack

Parameters:
Name Type Description
fn module:skyring/lib/server/route~Middleware

a the middelware function to add

Source: