Router Class
Responsible for routing a request through the registered middleware to serve up a response
Constructor
Router
-
req
-
res
Parameters:
-
req
Request -
res
Response
Item Index
Methods
- _handle
- addMiddlewareAfter static
- addMiddlewareAfterAll static
- addMiddlewareAt static
- addMiddlewareBefore static
- addMiddlewareBeforeAll static
- continueAfter
- continueAt
- handle
- indexOfMiddleware static
- redirect static
- removeMiddleware static
- replaceMiddleware static
Properties
- index
- middleware static
- req
- res
Methods
_handle
-
req
-
res
Handles the incoming request by executing each of the middleware in the pipeline
Parameters:
-
req
Request -
res
Response
addMiddlewareAfter
-
name
-
middleware
Adds middleware after the middleware with the specified name
Parameters:
-
name
String -
middleware
Object-
name
String -
action
Function
-
Returns:
addMiddlewareAfterAll
-
middleware
Adds middleware after all other registered middleware
Parameters:
-
middleware
Object-
name
String -
action
Function
-
Returns:
addMiddlewareAt
-
index
-
middleware
Adds middleware at the specified index
Parameters:
-
index
Number -
middleware
Object-
name
String -
action
Function
-
Returns:
TRUE if added, FALSE if the middleware already exists in the pipeline
addMiddlewareBefore
-
name
-
middleware
Adds middleware before the middleware with the specified name
Parameters:
-
name
String -
middleware
Object-
name
String -
action
Function
-
Returns:
addMiddlewareBeforeAll
-
middleware
Adds middleware before all other registered middleware
Parameters:
-
middleware
Object-
name
String -
action
Function
-
Returns:
continueAfter
-
middlewareName
Instructs the router to continue pipeline execution after the specified middleware.
Parameters:
-
middlewareName
String
continueAt
-
index
Instructs the router to continue processing at the specified position in the set of middleware being executed
Parameters:
-
index
Number
handle
()
Starts the execution of the middleware pipeline against the specified request/response pair
indexOfMiddleware
-
name
Determines the position in the middleware pipeline where the middleware executes.
Parameters:
-
name
String
Returns:
The position of the middleware or -1 when not found
redirect
-
location
-
httpStatusCode
Causes a redirect result to be created and set off of the Request object as the controllerResult. The pipeline is then instructed to continue after the "render" middleware
Parameters:
-
location
StringThe location to redirect to
-
httpStatusCode
NumberThe integer that represents the status code to be returned
removeMiddleware
-
name
Removes the specified middleware from the pipeline
Parameters:
-
name
String
Returns:
replaceMiddleware
-
name
-
middleware
Replaces the middleware with the specified name at its current position in the middleware pipeline
Parameters:
-
name
String -
middleware
Object-
name
String -
action
Function
-
Returns:
Properties
index
Number
Represents the current position of the middleware that is currently executing