Like {@link Route#blockingHandler} called with ordered = true
Specify a blocking request handler for the route. This method works just like {@link Route#handler} 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.
Add a content type consumed by this route. Used for content based routing.
Disable this route. While disabled the router will not route any requests or failures to it.
Enable this route.
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
Get some data from metadata.
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
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 of the path is a regular expression, this includes expression paths.
Specify this is the last route for the router.
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
Specify the order for this route. The router tests routes in that order.
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.
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.
Add a content type produced by this route. Used for content based routing.
Put metadata to this route. Used for saved extra data. Remove the existing value if value is null.
Remove this route from the router
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, {@link RoutingContext#end} has been called, then nothing shall happen. For the remaining cases, the following rules apply:
body
is null
then the status code of the response shall be 204 (NO CONTENT)body
is of type and the Content-Type
isn't set then the Content-Type
shall be application/octet-stream
body
is of type String and the Content-Type
isn't set then the Content-Type
shall be text/html
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.
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
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 /(?
Use a (sub) Router as a handler. There are several requirements to be fulfilled for this to be accepted.
Use {@link Route#useNormalizedPath} instead
If true then the normalized request path will be used when routing (e.g. removing duplicate /) Default is true
Add a virtual host filter for this route.
Generated using TypeDoc
A route is a holder for a set of criteria which determine whether an HTTP request or failure should be routed to a handler.