Package io.vertx.reactivex.ext.web

## Class Route

- java.lang.Object
- - io.vertx.reactivex.ext.web.Route

- All Implemented Interfaces:
    `io.vertx.lang.rx.RxDelegate`

      public class Route
      extends Object
      implements io.vertx.lang.rx.RxDelegate

  A route is a holder for a set of criteria which determine whether an HTTP request or failure should be routed to a handler.

  NOTE: This class has been automatically generated from the `original` non RX-ified interface using Vert.x codegen.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static io.vertx.lang.rx.TypeArg<Route>` | `__TYPE_ARG` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Route​(Route delegate)` |
    `Route​(Object delegate)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Route` | `blockingHandler​(Handler<RoutingContext> requestHandler)` | Like `blockingHandler(io.vertx.core.Handler<io.vertx.reactivex.ext.web.RoutingContext>)` called with ordered = true
    `Route` | `blockingHandler​(Handler<RoutingContext> requestHandler, boolean ordered)` | Specify a blocking request handler for the route.
    `Route` | `consumes​(String contentType)` | Add a content type consumed by this route.
    `Route` | `disable()` | Disable this route.
    `Route` | `enable()` | Enable this route.
    `boolean` | `equals​(Object o)` |
    `Route` | `failureHandler​(Handler<RoutingContext> failureHandler)` | Append a failure handler to the route failure handlers list.
    `Route` | `getDelegate()` |
    `<T> T` | `getMetadata​(String key)` | Get some data from metadata.
    `String` | `getName()` |
    `String` | `getPath()` |
    `Router` | `getSubRouter()` |
    `Route` | `handler​(Handler<RoutingContext> requestHandler)` | Append a request handler to the route handlers list.
    `int` | `hashCode()` |
    `boolean` | `isExactPath()` | Returns true of the path doesn't end with a wildcard `*` or is `null`.
    `boolean` | `isRegexPath()` | Returns true of the path is a regular expression, this includes expression paths.
    `Route` | `last()` | Specify this is the last route for the router.
    `Map<String,​Object>` | `metadata()` |
    `Route` | `method​(HttpMethod method)` | Add an HTTP method for this route.
    `Set<HttpMethod>` | `methods()` |
    `static Route` | `newInstance​(Route arg)` |
    `Route` | `order​(int order)` | Specify the order for this route.
    `Route` | `path​(String path)` | Set the path prefix for this route.
    `Route` | `pathRegex​(String path)` | Set the path prefix as a regular expression.
    `Route` | `produces​(String contentType)` | Add a content type produced by this route.
    `Route` | `putMetadata​(String key, Object value)` | Put metadata to this route.
    `Route` | `remove()` | Remove this route from the router
    `<T> Route` | `respond​(Function<RoutingContext,​Maybe<T>> function)` | Append a function request handler to the route handlers list.
    `<T> Route` | `respond​(Function<RoutingContext,​Future<T>> function)` | Append a function request handler to the route handlers list.
    `Route` | `setName​(String name)` | Giving a name to a route will provide this name as metadata to requests matching this route.
    `Route` | `setRegexGroupsNames​(List<String> groups)` | When you add a new route with a regular expression, you can add named capture groups for parameters.
    `Route` | `subRouter​(Router subRouter)` | Use a (sub) `Router` as a handler.
    `String` | `toString()` |
    `Route` | `useNormalizedPath​(boolean useNormalizedPath)` | If true then the normalized request path will be used when routing (e.g. removing duplicate /) Default is true
    `Route` | `virtualHost​(String hostnamePattern)` | Add a virtual host filter for this route.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### __TYPE_ARG

          public static final io.vertx.lang.rx.TypeArg<Route> __TYPE_ARG

  - ### Constructor Detail

    - #### Route

          public Route​(Route delegate)

    - #### Route

          public Route​(Object delegate)

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals​(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getDelegate

          public Route getDelegate()

      Specified by:
        `getDelegate` in interface `io.vertx.lang.rx.RxDelegate`

    - #### method

          public Route method​(HttpMethod method)

      Add an HTTP method for this route. By default a route will match all HTTP methods. If any are specified then the route will only match any of the specified methods
      Parameters:
        `method` - the HTTP method to add
      Returns:
        a reference to this, so the API can be used fluently

    - #### path

          public Route path​(String path)

      Set the path prefix for this route. If set then this route will only match request URI paths which start with this path prefix. Only a single path or path regex can be set for a route.
      Parameters:
        `path` - the path prefix
      Returns:
        a reference to this, so the API can be used fluently

    - #### pathRegex

          public Route pathRegex​(String path)

      Set the path prefix as a regular expression. If set then this route will only match request URI paths, the beginning of which match the regex. Only a single path or path regex can be set for a route.
      Parameters:
        `path` - the path regex
      Returns:
        a reference to this, so the API can be used fluently

    - #### produces

          public Route produces​(String contentType)

      Add a content type produced by this route. Used for content based routing.
      Parameters:
        `contentType` - the content type
      Returns:
        a reference to this, so the API can be used fluently

    - #### consumes

          public Route consumes​(String contentType)

      Add a content type consumed by this route. Used for content based routing.
      Parameters:
        `contentType` - the content type
      Returns:
        a reference to this, so the API can be used fluently

    - #### virtualHost

          public Route virtualHost​(String hostnamePattern)

      Add a virtual host filter for this route.
      Parameters:
        `hostnamePattern` - the hostname pattern that should match `Host` header of the requests
      Returns:
        a reference to this, so the API can be used fluently

    - #### order

          public Route order​(int order)

      Specify the order for this route. The router tests routes in that order.
      Parameters:
        `order` - the order
      Returns:
        a reference to this, so the API can be used fluently

    - #### last

          public Route last()

      Specify this is the last route for the router.
      Returns:
        a reference to this, so the API can be used fluently

    - #### handler

          public Route handler​(Handler<RoutingContext> requestHandler)

      Append a request handler to the route handlers list. The router routes requests to handlers depending on whether the various criteria such as method, path, etc match. When method, path, etc are the same for different routes, You should add multiple handlers to the same route object rather than creating two different routes objects with one handler for route
      Parameters:
        `requestHandler` - the request handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### blockingHandler

          public Route blockingHandler​(Handler<RoutingContext> requestHandler)

      Like `blockingHandler(io.vertx.core.Handler<io.vertx.reactivex.ext.web.RoutingContext>)` called with ordered = true
      Parameters:
        `requestHandler` -
      Returns:

    - #### subRouter

          public Route subRouter​(Router subRouter)

      Use a (sub) `Router` as a handler. There are several requirements to be fulfilled for this to be accepted.
      - The route path must end with a wild card
      - Parameters are allowed but full regex patterns not
      - No other handler can be registered before or after this call (but they can on a new route object for the same path)
      - Only 1 router per path object
      Parameters:
        `subRouter` - the router to add
      Returns:
        a reference to this, so the API can be used fluently

    - #### getSubRouter

          public Router getSubRouter()

      Returns:
        the sub router if this route acts as a sub router, `null` if it does not.

    - #### blockingHandler

          public Route blockingHandler​(Handler<RoutingContext> requestHandler,
                                       boolean ordered)

      Specify a blocking request handler for the route. This method works just like `handler(io.vertx.core.Handler<io.vertx.reactivex.ext.web.RoutingContext>)` excepted that it will run the blocking handler on a worker thread so that it won't block the event loop. Note that it's safe to call context.next() from the blocking handler as it will be executed on the event loop context (and not on the worker thread.

      If the blocking handler is ordered it means that any blocking handlers for the same context are never executed concurrently but always in the order they were called. The default value of ordered is true. If you do not want this behaviour and don't mind if your blocking handlers are executed in parallel you can set ordered to false.

      Parameters:
        `requestHandler` - the blocking request handler
        `ordered` - if true handlers are executed in sequence, otherwise are run in parallel
      Returns:
        a reference to this, so the API can be used fluently

    - #### failureHandler

          public Route failureHandler​(Handler<RoutingContext> failureHandler)

      Append a failure handler to the route failure handlers list. The router routes failures to failurehandlers depending on whether the various criteria such as method, path, etc match. When method, path, etc are the same for different routes, You should add multiple failure handlers to the same route object rather than creating two different routes objects with one failure handler for route
      Parameters:
        `failureHandler` - the request handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### remove

          public Route remove()

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

    - #### disable

          public Route disable()

      Disable this route. While disabled the router will not route any requests or failures to it.
      Returns:
        a reference to this, so the API can be used fluently

    - #### enable

          public Route enable()

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

    - #### useNormalizedPath

          public Route useNormalizedPath​(boolean useNormalizedPath)

      If true then the normalized request path will be used when routing (e.g. removing duplicate /) Default is true
      Parameters:
        `useNormalizedPath` - use normalized path for routing?
      Returns:
        a reference to this, so the API can be used fluently

    - #### getMetadata

          public <T> T getMetadata​(String key)

      Get some data from metadata.
      Parameters:
        `key` - the key for the metadata
      Returns:
        the data

    - #### getPath

          public String getPath()

      Returns:
        the path prefix (if any) for this route

    - #### isRegexPath

          public boolean isRegexPath()

      Returns true of the path is a regular expression, this includes expression paths.
      Returns:
        true if backed by a pattern.

    - #### isExactPath

          public boolean isExactPath()

      Returns true of the path doesn't end with a wildcard `*` or is `null`. Regular expression paths are always assumed to be exact.
      Returns:
        true if the path is exact.

    - #### methods

          public Set<HttpMethod> methods()

      Returns:
        the http methods accepted by this route

    - #### setRegexGroupsNames

          public Route setRegexGroupsNames​(List<String> groups)

      When you add a new route with a regular expression, you can add named capture groups for parameters.
      However, if you need more complex parameters names (like "param_name"), you can add parameters names with this function. You have to name capture groups in regex with names: "p0", "p1", "p2", ...
      For example: If you declare route with regex \/(?[a-z]*)\/(?[a-z]*) and group names ["param_a", "param-b"] for uri /hello/world you receive inside pathParams() the parameter param_a = "hello"
      Parameters:
        `groups` - group names
      Returns:
        a reference to this, so the API can be used fluently

    - #### setName

          public Route setName​(String name)

      Giving a name to a route will provide this name as metadata to requests matching this route. This metadata is used by metrics and is meant to group requests with different URI paths (due to parameters) by a common identifier, for example "/resource/:resourceID" common name
      Parameters:
        `name` - The name of the route.
      Returns:
        a reference to this, so the API can be used fluently

    - #### getName

          public String getName()

      Returns:
        the name of the route. If not given explicitly, the path or the pattern or null is returned (in that order)

    - #### respond

          public <T> Route respond​(Function<RoutingContext,​Future<T>> function)

      Append a function request handler to the route handlers list. The function expects to receive the routing context and users are expected to return a . The use of this functional interface allows users to quickly link the responses from other vert.x APIs or clients directly to a handler. If the context response has been ended, for example, `RoutingContext.end(java.lang.String)` has been called, then nothing shall happen. For the remaining cases, the following rules apply:
      1. When `body` is `null` then the status code of the response shall be 204 (NO CONTENT)
      2. When `body` is of type and the `Content-Type` isn't set then the `Content-Type` shall be `application/octet-stream`
      3. When `body` is of type `String` and the `Content-Type` isn't set then the `Content-Type` shall be `text/html`
      4. Otherwise the response of the future is then passed to the method `RoutingContext.json(java.lang.Object)` to perform a JSON serialization of the result
      Internally the function is wrapped as a handler that handles error cases for the user too. For example, if the function throws an exception the error will be catched and a proper error will be propagated throw the router. Also if the same happens while encoding the response, errors are catched and propagated to the router.
      Parameters:
        `function` - the request handler function
      Returns:
        a reference to this, so the API can be used fluently

    - #### respond

          public <T> Route respond​(Function<RoutingContext,​Maybe<T>> function)

      Append a function request handler to the route handlers list. The function expects to receive the routing context and users are expected to return a . The use of this functional interface allows users to quickly link the responses from other vert.x APIs or clients directly to a handler. If the context response has been ended, for example, `RoutingContext.end(java.lang.String)` has been called, then nothing shall happen. For the remaining cases, the following rules apply:
      1. When `body` is `null` then the status code of the response shall be 204 (NO CONTENT)
      2. When `body` is of type and the `Content-Type` isn't set then the `Content-Type` shall be `application/octet-stream`
      3. When `body` is of type `String` and the `Content-Type` isn't set then the `Content-Type` shall be `text/html`
      4. Otherwise the response of the future is then passed to the method `RoutingContext.json(java.lang.Object)` to perform a JSON serialization of the result
      Internally the function is wrapped as a handler that handles error cases for the user too. For example, if the function throws an exception the error will be catched and a proper error will be propagated throw the router. Also if the same happens while encoding the response, errors are catched and propagated to the router.
      Parameters:
        `function` - the request handler function
      Returns:
        a reference to this, so the API can be used fluently

    - #### putMetadata

          public Route putMetadata​(String key,
                                   Object value)

      Put metadata to this route. Used for saved extra data. Remove the existing value if value is null.
      Parameters:
        `key` - the metadata of key
        `value` - the metadata of value
      Returns:
        a reference to this, so the API can be used fluently

    - #### metadata

          public Map<String,​Object> metadata()

      Returns:
        the metadata of this route, never returns null.

    - #### newInstance

          public static Route newInstance​(Route arg)