# Class: Router

## vertx-web-js/router~ Router

#### new Router()

  Source:
    - router.js, line 32

### Methods

#### accept(request)

  This method is used to provide a request to the router. Usually you take request from the HttpServer#requestHandler and pass it to this method. The router then routes it to matching routes.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `request` | HttpServerRequest | the request

  Source:
    - router.js, line 45

#### clear() → {Router}

  Remove all the routes from this router
  Source:
    - router.js, line 379

  ##### Returns:

  a reference to this, so the API can be used fluently
  Type
    Router

#### connect(path) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `path` | string | URI paths that begin with this path will match

  Source:
    - router.js, line 305

  ##### Returns:

  the route
  Type
    Route

#### connectWithRegex(regex) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `regex` | string | URI paths that begin with a match for this regex will match

  Source:
    - router.js, line 321

  ##### Returns:

  the route
  Type
    Route

#### delete(path) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `path` | string | URI paths that begin with this path will match

  Source:
    - router.js, line 245

  ##### Returns:

  the route
  Type
    Route

#### deleteWithRegex(regex) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `regex` | string | URI paths that begin with a match for this regex will match

  Source:
    - router.js, line 261

  ##### Returns:

  the route
  Type
    Route

#### exceptionHandler(exceptionHandler) → {Router}

  Specify a handler for any unhandled exceptions on this router. The handler will be called for exceptions thrown from handlers. This does not affect the normal failure routing logic.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `exceptionHandler` | function | the exception handler

  Source:
    - router.js, line 411

  ##### Returns:

  a reference to this, so the API can be used fluently
  Type
    Router

#### get(path) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `path` | string | URI paths that begin with this path will match

  Source:
    - router.js, line 95

  ##### Returns:

  the route
  Type
    Route

#### getRoutes() → {Array.<Route>}

  Source:
    - router.js, line 365

  ##### Returns:

  - a list of all the routes on this router
  - Type
      Array.<Route>

#### getWithRegex(regex) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `regex` | string | URI paths that begin with a match for this regex will match

  Source:
    - router.js, line 111

  ##### Returns:

  the route
  Type
    Route

#### handleContext(context)

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `context` | RoutingContext | the routing context

  Source:
    - router.js, line 427

#### handleFailure(context)

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `context` | RoutingContext | the routing context

  Source:
    - router.js, line 440

#### head(path) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `path` | string | URI paths that begin with this path will match

  Source:
    - router.js, line 125

  ##### Returns:

  the route
  Type
    Route

#### headWithRegex(regex) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `regex` | string | URI paths that begin with a match for this regex will match

  Source:
    - router.js, line 141

  ##### Returns:

  the route
  Type
    Route

#### mountSubRouter(mountPoint, subRouter) → {Router}

  Mount a sub router on this router

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `mountPoint` | string | the mount point (path prefix) to mount it on
  `subRouter` | Router | the router to mount as a sub router

  Source:
    - router.js, line 395

  ##### Returns:

  a reference to this, so the API can be used fluently
  Type
    Router

#### options(path) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `path` | string | URI paths that begin with this path will match

  Source:
    - router.js, line 155

  ##### Returns:

  the route
  Type
    Route

#### optionsWithRegex(regex) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `regex` | string | URI paths that begin with a match for this regex will match

  Source:
    - router.js, line 171

  ##### Returns:

  the route
  Type
    Route

#### patch(path) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `path` | string | URI paths that begin with this path will match

  Source:
    - router.js, line 335

  ##### Returns:

  the route
  Type
    Route

#### patchWithRegex(regex) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `regex` | string | URI paths that begin with a match for this regex will match

  Source:
    - router.js, line 351

  ##### Returns:

  the route
  Type
    Route

#### post(path) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `path` | string | URI paths that begin with this path will match

  Source:
    - router.js, line 215

  ##### Returns:

  the route
  Type
    Route

#### postWithRegex(regex) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `regex` | string | URI paths that begin with a match for this regex will match

  Source:
    - router.js, line 231

  ##### Returns:

  the route
  Type
    Route

#### put(path) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `path` | string | URI paths that begin with this path will match

  Source:
    - router.js, line 185

  ##### Returns:

  the route
  Type
    Route

#### putWithRegex(regex) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `regex` | string | URI paths that begin with a match for this regex will match

  Source:
    - router.js, line 201

  ##### Returns:

  the route
  Type
    Route

#### route(method, path) → {Route}

  Add a route that matches the specified HTTP method and path

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `method` | Object | the HTTP method to match
  `path` | string | URI paths that begin with this path will match

  Source:
    - router.js, line 60

  ##### Returns:

  the route
  Type
    Route

#### routeWithRegex(method, regex) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `method` | Object | the HTTP method to match
  `regex` | string | URI paths that begin with a match for this regex will match

  Source:
    - router.js, line 79

  ##### Returns:

  the route
  Type
    Route

#### trace(path) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `path` | string | URI paths that begin with this path will match

  Source:
    - router.js, line 275

  ##### Returns:

  the route
  Type
    Route

#### traceWithRegex(regex) → {Route}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `regex` | string | URI paths that begin with a match for this regex will match

  Source:
    - router.js, line 291

  ##### Returns:

  the route
  Type
    Route