Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Router

A router receives request from an {@link HttpServer} and routes it to the first matching Route that it contains. A router can contain many routes.

Routers are also used for routing failures.

Hierarchy

  • Router

Implements

  • any

Index

Methods

allowForward

  • Set whether the router should parse "forwarded"-type headers

    Parameters

    Returns Router

clear

  • Remove all the routes from this router

    Returns Router

connect

  • Add a route that matches any HTTP CONNECT request

    Returns Route

  • Add a route that matches a HTTP CONNECT request and the specified path

    Parameters

    • path: string

    Returns Route

connectWithRegex

  • connectWithRegex(regex: string): Route
  • Add a route that matches a HTTP CONNECT request and the specified path regex

    Parameters

    • regex: string

    Returns Route

delete

  • Add a route that matches any HTTP DELETE request

    Returns Route

  • Add a route that matches a HTTP DELETE request and the specified path

    Parameters

    • path: string

    Returns Route

deleteWithRegex

  • deleteWithRegex(regex: string): Route
  • Add a route that matches a HTTP DELETE request and the specified path regex

    Parameters

    • regex: string

    Returns Route

errorHandler

  • Specify an handler to handle an error for a particular status code. You can use to manage general errors too using status code 500. The handler will be called when the context fails and other failure handlers didn't write the reply or when an exception is thrown inside an handler. You must not use {@link RoutingContext#next} inside the error handler This does not affect the normal failure routing logic.

    Parameters

    Returns Router

get

  • Add a route that matches any HTTP GET request

    Returns Route

  • Add a route that matches a HTTP GET request and the specified path

    Parameters

    • path: string

    Returns Route

getMetadata

  • getMetadata<T>(key: string): T
  • Get some data from metadata.

    Type parameters

    • T

    Parameters

    • key: string

    Returns T

getRoutes

  • Returns Route

getWithRegex

  • getWithRegex(regex: string): Route
  • Add a route that matches a HTTP GET request and the specified path regex

    Parameters

    • regex: string

    Returns Route

handle

  • handle(arg0: HttpServerRequest): void
  • Parameters

    • arg0: HttpServerRequest

    Returns void

handleContext

  • Used to route a context to the router. Used for sub-routers. You wouldn't normally call this method directly.

    Parameters

    Returns void

handleFailure

  • Used to route a failure to the router. Used for sub-routers. You wouldn't normally call this method directly.

    Parameters

    Returns void

head

  • Add a route that matches any HTTP HEAD request

    Returns Route

  • Add a route that matches a HTTP HEAD request and the specified path

    Parameters

    • path: string

    Returns Route

headWithRegex

  • headWithRegex(regex: string): Route
  • Add a route that matches a HTTP HEAD request and the specified path regex

    Parameters

    • regex: string

    Returns Route

metadata

  • metadata(): {}
  • Returns {}

    • [key: string]: any

modifiedHandler

  • When a Router routes are changed this handler is notified. This is useful for routes that depend on the state of the router.

    Parameters

    Returns Router

mountSubRouter

  • mountSubRouter(mountPoint: string, subRouter: Router): Route
  • Parameters

    • mountPoint: string
    • subRouter: Router

    Returns Route

options

  • Add a route that matches any HTTP OPTIONS request

    Returns Route

  • Add a route that matches a HTTP OPTIONS request and the specified path

    Parameters

    • path: string

    Returns Route

optionsWithRegex

  • optionsWithRegex(regex: string): Route
  • Add a route that matches a HTTP OPTIONS request and the specified path regex

    Parameters

    • regex: string

    Returns Route

patch

  • Add a route that matches any HTTP PATCH request

    Returns Route

  • Add a route that matches a HTTP PATCH request and the specified path

    Parameters

    • path: string

    Returns Route

patchWithRegex

  • patchWithRegex(regex: string): Route
  • Add a route that matches a HTTP PATCH request and the specified path regex

    Parameters

    • regex: string

    Returns Route

post

  • Add a route that matches any HTTP POST request

    Returns Route

  • Add a route that matches a HTTP POST request and the specified path

    Parameters

    • path: string

    Returns Route

postWithRegex

  • postWithRegex(regex: string): Route
  • Add a route that matches a HTTP POST request and the specified path regex

    Parameters

    • regex: string

    Returns Route

put

  • Add a route that matches any HTTP PUT request

    Returns Route

  • Add a route that matches a HTTP PUT request and the specified path

    Parameters

    • path: string

    Returns Route

putMetadata

  • putMetadata(key: string, value: any): Router
  • Put metadata to this router. Used for saved extra data. Remove the existing value if value is null.

    Parameters

    • key: string
    • value: any

    Returns Router

putWithRegex

  • putWithRegex(regex: string): Route
  • Add a route that matches a HTTP PUT request and the specified path regex

    Parameters

    • regex: string

    Returns Route

route

  • route(): Route
  • route(method: HttpMethod, path: string): Route
  • route(path: string): Route
  • Add a route with no matching criteria, i.e. it matches all requests or failures.

    Returns Route

  • Add a route that matches the specified HTTP method and path

    Parameters

    • method: HttpMethod
    • path: string

    Returns Route

  • Add a route that matches the specified path

    Parameters

    • path: string

    Returns Route

routeWithRegex

  • routeWithRegex(method: HttpMethod, regex: string): Route
  • routeWithRegex(regex: string): Route
  • Add a route that matches the specified HTTP method and path regex

    Parameters

    • method: HttpMethod
    • regex: string

    Returns Route

  • Add a route that matches the specified path regex

    Parameters

    • regex: string

    Returns Route

trace

  • Add a route that matches any HTTP TRACE request

    Returns Route

  • Add a route that matches a HTTP TRACE request and the specified path

    Parameters

    • path: string

    Returns Route

traceWithRegex

  • traceWithRegex(regex: string): Route
  • Add a route that matches a HTTP TRACE request and the specified path regex

    Parameters

    • regex: string

    Returns Route

Static router

  • router(vertx: Vertx): Router
  • Create a router

    Parameters

    • vertx: Vertx

    Returns Router

Generated using TypeDoc