io.vertx.ext.web

## Interface Router

-     public interface Router

  A router receives request from an `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.

  Author:
    Tim Fox

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `accept(HttpServerRequest request)` This method is used to provide a request to the router.
    `Router` | `clear()` Remove all the routes from this router
    `Route` | `connect()` Add a route that matches any HTTP CONNECT request
    `Route` | `connect(String path)` Add a route that matches a HTTP CONNECT request and the specified path
    `Route` | `connectWithRegex(String regex)` Add a route that matches a HTTP CONNECT request and the specified path regex
    `Route` | `delete()` Add a route that matches any HTTP DELETE request
    `Route` | `delete(String path)` Add a route that matches a HTTP DELETE request and the specified path
    `Route` | `deleteWithRegex(String regex)` Add a route that matches a HTTP DELETE request and the specified path regex
    `Router` | `exceptionHandler(Handler<Throwable> exceptionHandler)` Specify a handler for any unhandled exceptions on this router.
    `Route` | `get()` Add a route that matches any HTTP GET request
    `Route` | `get(String path)` Add a route that matches a HTTP GET request and the specified path
    `List<Route>` | `getRoutes()`
    `Route` | `getWithRegex(String regex)` Add a route that matches a HTTP GET request and the specified path regex
    `void` | `handleContext(RoutingContext context)` Used to route a context to the router.
    `void` | `handleFailure(RoutingContext context)` Used to route a failure to the router.
    `Route` | `head()` Add a route that matches any HTTP HEAD request
    `Route` | `head(String path)` Add a route that matches a HTTP HEAD request and the specified path
    `Route` | `headWithRegex(String regex)` Add a route that matches a HTTP HEAD request and the specified path regex
    `Router` | `mountSubRouter(String mountPoint, Router subRouter)` Mount a sub router on this router
    `Route` | `options()` Add a route that matches any HTTP OPTIONS request
    `Route` | `options(String path)` Add a route that matches a HTTP OPTIONS request and the specified path
    `Route` | `optionsWithRegex(String regex)` Add a route that matches a HTTP OPTIONS request and the specified path regex
    `Route` | `patch()` Add a route that matches any HTTP PATCH request
    `Route` | `patch(String path)` Add a route that matches a HTTP PATCH request and the specified path
    `Route` | `patchWithRegex(String regex)` Add a route that matches a HTTP PATCH request and the specified path regex
    `Route` | `post()` Add a route that matches any HTTP POST request
    `Route` | `post(String path)` Add a route that matches a HTTP POST request and the specified path
    `Route` | `postWithRegex(String regex)` Add a route that matches a HTTP POST request and the specified path regex
    `Route` | `put()` Add a route that matches any HTTP PUT request
    `Route` | `put(String path)` Add a route that matches a HTTP PUT request and the specified path
    `Route` | `putWithRegex(String regex)` Add a route that matches a HTTP PUT request and the specified path regex
    `Route` | `route()` Add a route with no matching criteria, i.e.
    `Route` | `route(HttpMethod method, String path)` Add a route that matches the specified HTTP method and path
    `Route` | `route(String path)` Add a route that matches the specified path
    `static Router` | `router(Vertx vertx)` Create a router
    `Route` | `routeWithRegex(HttpMethod method, String regex)` Add a route that matches the specified HTTP method and path regex
    `Route` | `routeWithRegex(String regex)` Add a route that matches the specified path regex
    `Route` | `trace()` Add a route that matches any HTTP TRACE request
    `Route` | `trace(String path)` Add a route that matches a HTTP TRACE request and the specified path
    `Route` | `traceWithRegex(String regex)` Add a route that matches a HTTP TRACE request and the specified path regex

- - ### Method Detail

    - #### router

          static Router router(Vertx vertx)

      Create a router
      Parameters:
        `vertx` - the Vert.x instance
      Returns:
        the router

    - #### accept

          void accept(HttpServerRequest request)

      This method is used to provide a request to the router. Usually you take request from the `HttpServer.requestHandler(Handler)` and pass it to this method. The router then routes it to matching routes.
      Parameters:
        `request` - the request

    - #### route

          Route route()

      Add a route with no matching criteria, i.e. it matches all requests or failures.
      Returns:
        the route

    - #### route

          Route route(HttpMethod method,
                      String path)

      Add a route that matches the specified HTTP method and path
      Parameters:
        `method` - the HTTP method to match
        `path` - URI paths that begin with this path will match
      Returns:
        the route

    - #### route

          Route route(String path)

      Add a route that matches the specified path
      Parameters:
        `path` - URI paths that begin with this path will match
      Returns:
        the route

    - #### routeWithRegex

          Route routeWithRegex(HttpMethod method,
                               String regex)

      Add a route that matches the specified HTTP method and path regex
      Parameters:
        `method` - the HTTP method to match
        `regex` - URI paths that begin with a match for this regex will match
      Returns:
        the route

    - #### routeWithRegex

          Route routeWithRegex(String regex)

      Add a route that matches the specified path regex
      Parameters:
        `regex` - URI paths that begin with a match for this regex will match
      Returns:
        the route

    - #### get

          Route get()

      Add a route that matches any HTTP GET request
      Returns:
        the route

    - #### get

          Route get(String path)

      Add a route that matches a HTTP GET request and the specified path
      Parameters:
        `path` - URI paths that begin with this path will match
      Returns:
        the route

    - #### getWithRegex

          Route getWithRegex(String regex)

      Add a route that matches a HTTP GET request and the specified path regex
      Parameters:
        `regex` - URI paths that begin with a match for this regex will match
      Returns:
        the route

    - #### head

          Route head()

      Add a route that matches any HTTP HEAD request
      Returns:
        the route

    - #### head

          Route head(String path)

      Add a route that matches a HTTP HEAD request and the specified path
      Parameters:
        `path` - URI paths that begin with this path will match
      Returns:
        the route

    - #### headWithRegex

          Route headWithRegex(String regex)

      Add a route that matches a HTTP HEAD request and the specified path regex
      Parameters:
        `regex` - URI paths that begin with a match for this regex will match
      Returns:
        the route

    - #### options

          Route options()

      Add a route that matches any HTTP OPTIONS request
      Returns:
        the route

    - #### options

          Route options(String path)

      Add a route that matches a HTTP OPTIONS request and the specified path
      Parameters:
        `path` - URI paths that begin with this path will match
      Returns:
        the route

    - #### optionsWithRegex

          Route optionsWithRegex(String regex)

      Add a route that matches a HTTP OPTIONS request and the specified path regex
      Parameters:
        `regex` - URI paths that begin with a match for this regex will match
      Returns:
        the route

    - #### put

          Route put()

      Add a route that matches any HTTP PUT request
      Returns:
        the route

    - #### put

          Route put(String path)

      Add a route that matches a HTTP PUT request and the specified path
      Parameters:
        `path` - URI paths that begin with this path will match
      Returns:
        the route

    - #### putWithRegex

          Route putWithRegex(String regex)

      Add a route that matches a HTTP PUT request and the specified path regex
      Parameters:
        `regex` - URI paths that begin with a match for this regex will match
      Returns:
        the route

    - #### post

          Route post()

      Add a route that matches any HTTP POST request
      Returns:
        the route

    - #### post

          Route post(String path)

      Add a route that matches a HTTP POST request and the specified path
      Parameters:
        `path` - URI paths that begin with this path will match
      Returns:
        the route

    - #### postWithRegex

          Route postWithRegex(String regex)

      Add a route that matches a HTTP POST request and the specified path regex
      Parameters:
        `regex` - URI paths that begin with a match for this regex will match
      Returns:
        the route

    - #### delete

          Route delete()

      Add a route that matches any HTTP DELETE request
      Returns:
        the route

    - #### delete

          Route delete(String path)

      Add a route that matches a HTTP DELETE request and the specified path
      Parameters:
        `path` - URI paths that begin with this path will match
      Returns:
        the route

    - #### deleteWithRegex

          Route deleteWithRegex(String regex)

      Add a route that matches a HTTP DELETE request and the specified path regex
      Parameters:
        `regex` - URI paths that begin with a match for this regex will match
      Returns:
        the route

    - #### trace

          Route trace()

      Add a route that matches any HTTP TRACE request
      Returns:
        the route

    - #### trace

          Route trace(String path)

      Add a route that matches a HTTP TRACE request and the specified path
      Parameters:
        `path` - URI paths that begin with this path will match
      Returns:
        the route

    - #### traceWithRegex

          Route traceWithRegex(String regex)

      Add a route that matches a HTTP TRACE request and the specified path regex
      Parameters:
        `regex` - URI paths that begin with a match for this regex will match
      Returns:
        the route

    - #### connect

          Route connect()

      Add a route that matches any HTTP CONNECT request
      Returns:
        the route

    - #### connect

          Route connect(String path)

      Add a route that matches a HTTP CONNECT request and the specified path
      Parameters:
        `path` - URI paths that begin with this path will match
      Returns:
        the route

    - #### connectWithRegex

          Route connectWithRegex(String regex)

      Add a route that matches a HTTP CONNECT request and the specified path regex
      Parameters:
        `regex` - URI paths that begin with a match for this regex will match
      Returns:
        the route

    - #### patch

          Route patch()

      Add a route that matches any HTTP PATCH request
      Returns:
        the route

    - #### patch

          Route patch(String path)

      Add a route that matches a HTTP PATCH request and the specified path
      Parameters:
        `path` - URI paths that begin with this path will match
      Returns:
        the route

    - #### patchWithRegex

          Route patchWithRegex(String regex)

      Add a route that matches a HTTP PATCH request and the specified path regex
      Parameters:
        `regex` - URI paths that begin with a match for this regex will match
      Returns:
        the route

    - #### getRoutes

          List<Route> getRoutes()

      Returns:
        a list of all the routes on this router

    - #### clear

          Router clear()

      Remove all the routes from this router
      Returns:
        a reference to this, so the API can be used fluently

    - #### mountSubRouter

          Router mountSubRouter(String mountPoint,
                                Router subRouter)

      Mount a sub router on this router
      Parameters:
        `mountPoint` - the mount point (path prefix) to mount it on
        `subRouter` - the router to mount as a sub router
      Returns:
        a reference to this, so the API can be used fluently

    - #### exceptionHandler

          Router exceptionHandler(Handler<Throwable> exceptionHandler)

      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:
        `exceptionHandler` - the exception handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### handleContext

          void handleContext(RoutingContext context)

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

    - #### handleFailure

          void handleFailure(RoutingContext context)

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

Copyright © 2016. All rights reserved.