API Docs for: 0.8.0
Show:

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

Methods

_handle

(
  • req
  • res
)
private

Handles the incoming request by executing each of the middleware in the pipeline

Parameters:

  • req Request
  • res Response

addMiddlewareAfter

(
  • name
  • middleware
)
Boolean static

Adds middleware after the middleware with the specified name

Parameters:

  • name String
  • middleware Object
    • name String
    • action Function

Returns:

Boolean:

addMiddlewareAfterAll

(
  • middleware
)
Boolean static

Adds middleware after all other registered middleware

Parameters:

  • middleware Object
    • name String
    • action Function

Returns:

Boolean:

addMiddlewareAt

(
  • index
  • middleware
)
Boolean static

Adds middleware at the specified index

Parameters:

  • index Number
  • middleware Object
    • name String
    • action Function

Returns:

Boolean:

TRUE if added, FALSE if the middleware already exists in the pipeline

addMiddlewareBefore

(
  • name
  • middleware
)
Boolean static

Adds middleware before the middleware with the specified name

Parameters:

  • name String
  • middleware Object
    • name String
    • action Function

Returns:

Boolean:

addMiddlewareBeforeAll

(
  • middleware
)
Boolean static

Adds middleware before all other registered middleware

Parameters:

  • middleware Object
    • name String
    • action Function

Returns:

Boolean:

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
)
Number static

Determines the position in the middleware pipeline where the middleware executes.

Parameters:

  • name String

Returns:

Number:

The position of the middleware or -1 when not found

redirect

(
  • location
  • httpStatusCode
)
static

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 String

    The location to redirect to

  • httpStatusCode Number

    The integer that represents the status code to be returned

removeMiddleware

(
  • name
)
Boolean static

Removes the specified middleware from the pipeline

Parameters:

  • name String

Returns:

Boolean:

replaceMiddleware

(
  • name
  • middleware
)
Boolean static

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:

Boolean:

Properties

index

Number

Represents the current position of the middleware that is currently executing

middleware

Array static

req

Request

res

Response