Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Router

Hierarchy

  • Router

Index

Properties

defaultRoute

defaultRoute: Route = new DefaultRoute()

The default route that will be matched if no other routes matched.

The default implementation is to return a 404 response.

Readonly routes

routes: Route[] = []

Routes that will be tested against in order.

useLegacyCallbackHandler

useLegacyCallbackHandler: boolean = process.version.startsWith("v4.3") || process.version.startsWith("v6.10")

Both node 4.3 and 6.10 use the callback parameter to return a result. The ability to create new functions using Node.js 4.3 will be disabled July 31, 2018. Code updates to existing functions using Node.js v4.3 will be disabled on October 31, 2018. When the ability to update code in node 6.10 functions is disabled this can be removed.

Methods

errorHandler

  • errorHandler(err: Error): void
  • The handler that will be called when non-RestErrors are thrown. The handler can return nothing, a RouterResponse, or a Promise that resolves such. If a RouterResponse or Promise of RouterResponse is returned that will be the response used.

    The handler will be called with: the Error thrown, the input ProxyEvent that caused the error and the Lambda context.

    The default implementation is to log the error.

    Parameters

    Returns void

getLambdaHandler

route

  • route(path?: string | RegExp): RouteBuilder
  • route<T>(route: T): T
  • Start a BuildableRoute with the given string or regex path.

    Parameters

    • Optional path: string | RegExp

    Returns RouteBuilder

  • Add a custom Route.

    Type parameters

    Parameters

    • route: T

    Returns T

Generated using TypeDoc