Router

Introduced in 4.0.0

Stability: 2 - Stable

const Router = require('kado/lib/Router')

The Router library provides assistance for matching paths or URIs to real locations within the system.

static Router.redirectRequest (res)

static Router.renderJSON (res)

static Router.sendFile (req, res)

Usage:

const filepath = './foo.txt'
res.sendFile(filepath)

This method will set the Content-Length, Content-Type and ETag for the file as well as handle responding properly to HEAD requests. Useful for sending files back to the consumer.

static Router.render(app, req, res)

If there is no view engine false is returned.

static Router.getRemoteIP (app, req)

static Router.setPoweredBy (res)

Sets the powered by Kado header for the response.

static Router.standardPreparation(app)

static Router.getInstance()

Router.constructor()

Router.setPreparer(preparer)

Router.getPreparer()

Router.use(fn)

Add middleware to the system to be executed before the route is called.

Router.unuse(fn)

Router.final(fn)

Replaces the final handler with this function. By default the final handler is a noop function.

Router.add(method, uri, fn)

Adds a new route to the system with the specified handler.

Router.update(method, uri, fn)

Router.remove(method, uri)

Router.get(httpMethod, uri, params)

Router.callPreparer(req, res)

Internal Use

Router.callMiddleware(req, res, middlewareKeys)

Internal Use

Router.request(req, res)

Used by the HyperTextServer.onRequest() method.

Router.all()

Router.allForTemplate(replaceSplashes)