Router Class
Responsible for routing a request through the registered middleware to serve up a response
Constructor
Router
-
req -
res
Parameters:
-
reqRequest -
resResponse
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:
-
reqRequest -
resResponse
addMiddlewareAfter
-
name -
middleware
Adds middleware after the middleware with the specified name
Parameters:
-
nameString -
middlewareObject-
nameString -
actionFunction
-
Returns:
addMiddlewareAfterAll
-
middleware
Adds middleware after all other registered middleware
Parameters:
-
middlewareObject-
nameString -
actionFunction
-
Returns:
addMiddlewareAt
-
index -
middleware
Adds middleware at the specified index
Parameters:
-
indexNumber -
middlewareObject-
nameString -
actionFunction
-
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:
-
nameString -
middlewareObject-
nameString -
actionFunction
-
Returns:
addMiddlewareBeforeAll
-
middleware
Adds middleware before all other registered middleware
Parameters:
-
middlewareObject-
nameString -
actionFunction
-
Returns:
continueAfter
-
middlewareName
Instructs the router to continue pipeline execution after the specified middleware.
Parameters:
-
middlewareNameString
continueAt
-
index
Instructs the router to continue processing at the specified position in the set of middleware being executed
Parameters:
-
indexNumber
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:
-
nameString
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:
-
locationStringThe location to redirect to
-
httpStatusCodeNumberThe integer that represents the status code to be returned
removeMiddleware
-
name
Removes the specified middleware from the pipeline
Parameters:
-
nameString
Returns:
replaceMiddleware
-
name -
middleware
Replaces the middleware with the specified name at its current position in the middleware pipeline
Parameters:
-
nameString -
middlewareObject-
nameString -
actionFunction
-
Returns:
Properties
index
Number
Represents the current position of the middleware that is currently executing
