Package: io.vertx.groovy.ext.web

## [Groovy] Class Router

- io.vertx.groovy.ext.web.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.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `Router (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name 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(java.lang.String path)` Add a route that matches a HTTP CONNECT request and the specified path
    `Route` | `connectWithRegex(java.lang.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(java.lang.String path)` Add a route that matches a HTTP DELETE request and the specified path
    `Route` | `deleteWithRegex(java.lang.String regex)` Add a route that matches a HTTP DELETE request and the specified path regex
    `Router` | `exceptionHandler(io.vertx.core.Handler<java.lang.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(java.lang.String path)` Add a route that matches a HTTP GET request and the specified path
    `java.lang.Object` | `getDelegate()`
    `java.util.List<Route>` | `getRoutes()` @return a list of all the routes on this router
    `Route` | `getWithRegex(java.lang.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(java.lang.String path)` Add a route that matches a HTTP HEAD request and the specified path
    `Route` | `headWithRegex(java.lang.String regex)` Add a route that matches a HTTP HEAD request and the specified path regex
    `Router` | `mountSubRouter(java.lang.String mountPoint, Router subRouter)` Mount a sub router on this router
    `Route` | `options()` Add a route that matches any HTTP OPTIONS request
    `Route` | `options(java.lang.String path)` Add a route that matches a HTTP OPTIONS request and the specified path
    `Route` | `optionsWithRegex(java.lang.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(java.lang.String path)` Add a route that matches a HTTP PATCH request and the specified path
    `Route` | `patchWithRegex(java.lang.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(java.lang.String path)` Add a route that matches a HTTP POST request and the specified path
    `Route` | `postWithRegex(java.lang.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(java.lang.String path)` Add a route that matches a HTTP PUT request and the specified path
    `Route` | `putWithRegex(java.lang.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. it matches all requests or failures.
    `Route` | `route(io.vertx.core.http.HttpMethod method, java.lang.String path)` Add a route that matches the specified HTTP method and path
    `Route` | `route(java.lang.String path)` Add a route that matches the specified path
    `Route` | `routeWithRegex(io.vertx.core.http.HttpMethod method, java.lang.String regex)` Add a route that matches the specified HTTP method and path regex
    `Route` | `routeWithRegex(java.lang.String regex)` Add a route that matches the specified path regex
    `static Router` | `router(Vertx vertx)` Create a router
    `Route` | `trace()` Add a route that matches any HTTP TRACE request
    `Route` | `trace(java.lang.String path)` Add a route that matches a HTTP TRACE request and the specified path
    `Route` | `traceWithRegex(java.lang.String regex)` Add a route that matches a HTTP TRACE request and the specified path regex

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### Router(java.lang.Object delegate)

  - ### Method Detail

    - #### void accept(HttpServerRequest 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:
        `request` - the request

    - #### Router clear()

      Remove all the routes from this router

      Returns:
        a reference to this, so the API can be used fluently

    - #### Route connect()

      Add a route that matches any HTTP CONNECT request

      Returns:
        the route

    - #### Route connect(java.lang.String path)

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

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

    - #### Route connectWithRegex(java.lang.String regex)

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

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

    - #### Route delete()

      Add a route that matches any HTTP DELETE request

      Returns:
        the route

    - #### Route delete(java.lang.String path)

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

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

    - #### Route deleteWithRegex(java.lang.String regex)

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

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

    - #### Router exceptionHandler(io.vertx.core.Handler<java.lang.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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `exceptionHandler` - the exception handler

    - #### Route get()

      Add a route that matches any HTTP GET request

      Returns:
        the route

    - #### Route get(java.lang.String path)

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

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

    - #### java.lang.Object getDelegate()

    - #### java.util.List<Route> getRoutes()

      Returns:
        a list of all the routes on this router

    - #### Route getWithRegex(java.lang.String regex)

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

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

    - #### 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

    - #### 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

    - #### Route head()

      Add a route that matches any HTTP HEAD request

      Returns:
        the route

    - #### Route head(java.lang.String path)

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

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

    - #### Route headWithRegex(java.lang.String regex)

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

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

    - #### Router mountSubRouter(java.lang.String mountPoint, Router subRouter)

      Mount a sub router on this router

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

    - #### Route options()

      Add a route that matches any HTTP OPTIONS request

      Returns:
        the route

    - #### Route options(java.lang.String path)

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

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

    - #### Route optionsWithRegex(java.lang.String regex)

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

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

    - #### Route patch()

      Add a route that matches any HTTP PATCH request

      Returns:
        the route

    - #### Route patch(java.lang.String path)

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

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

    - #### Route patchWithRegex(java.lang.String regex)

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

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

    - #### Route post()

      Add a route that matches any HTTP POST request

      Returns:
        the route

    - #### Route post(java.lang.String path)

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

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

    - #### Route postWithRegex(java.lang.String regex)

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

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

    - #### Route put()

      Add a route that matches any HTTP PUT request

      Returns:
        the route

    - #### Route put(java.lang.String path)

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

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

    - #### Route putWithRegex(java.lang.String regex)

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

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

    - #### Route route()

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

      Returns:
        the route

    - #### Route route(io.vertx.core.http.HttpMethod method, java.lang.String path)

      Add a route that matches the specified HTTP method and path

      Returns:
        the route
      Parameters:
        `method` - the HTTP method to match
        `path` - URI paths that begin with this path will match

    - #### Route route(java.lang.String path)

      Add a route that matches the specified path

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

    - #### Route routeWithRegex(io.vertx.core.http.HttpMethod method, java.lang.String regex)

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

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

    - #### Route routeWithRegex(java.lang.String regex)

      Add a route that matches the specified path regex

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

    - #### static Router router(Vertx vertx)

      Create a router

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

    - #### Route trace()

      Add a route that matches any HTTP TRACE request

      Returns:
        the route

    - #### Route trace(java.lang.String path)

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

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

    - #### Route traceWithRegex(java.lang.String regex)

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

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