The main router class will route all the incoming requests.


Methods

addCustomRoute (source, destination)

This method adds a custom route.

Parameters

Name Type Description
source String/ Array The request to match.
destination String The destination to which the matched request needs to go.

Returned Value

Router: The current router object for chaining.


addParseRule (funct)

This method adds a custom ParseRule. A parseRule is a function customly defined in which you can add your own functionality to match a route.

Parameters

Name Type Description
funct Function The function for your custom parser.

Returned Value

Router: The current Route object for chaining.


parseRoutes (url)

This method parses the received route and will match it against the predefined routes. Also it will try to parse the requests to specific rules that can be added.

Parameters

Name Type Description
url String The requested url.

Returned Value

Object: A parsed url object.


route (request, response)

This method does some needed checks and routes the request. After the route is done the component has taken over the responsibility of forwarding it to the correct dispatcher.

Parameters

Name Type Description
request Request The nodejs Request object.
response Response The nodejs Response object.

Returned Value

Boolean: True when the route is successfull, false otherwise.


setPublicPath (path)

This method will set a public path, it will check if the request is send to a file, if so the requested file will be returned.

Parameters

Name Type Description
path String The path to the public directory.

Returned Value

Router: Router object for chaining.