A router receives request from an io.vertx.core.http.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.

  • Router
    • Basic
      • Identifiable
      • Object
        • Anything

no subtypes hierarchy

Initializer
Router(Router unknown)
Inherited Attributes
Attributes inherited from: Object
hash, string
Methods
acceptshared default void accept(HttpServerRequest request)

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

Parameters:
  • request

    the request

clearshared default Router clear()

Remove all the routes from this router

connectshared default Route connect()

Add a route that matches any HTTP CONNECT request

connectshared default 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

connectWithRegexshared default 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

deleteshared default Route delete()

Add a route that matches any HTTP DELETE request

deleteshared default 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

deleteWithRegexshared default 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

exceptionHandlershared default Router exceptionHandler(Anything(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

getshared default Route get()

Add a route that matches any HTTP GET request

getshared default 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

getRoutesshared default List<Route> getRoutes()
getWithRegexshared default 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

handleContextshared default 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

handleFailureshared default 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

shared default Route head()

Add a route that matches any HTTP HEAD request

headshared default 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

headWithRegexshared default 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

mountSubRoutershared default 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

optionsshared default Route options()

Add a route that matches any HTTP OPTIONS request

optionsshared default 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

optionsWithRegexshared default 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

patchshared default Route patch()

Add a route that matches any HTTP PATCH request

patchshared default 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

patchWithRegexshared default 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

postshared default Route post()

Add a route that matches any HTTP POST request

postshared default 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

postWithRegexshared default 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

putshared default Route put()

Add a route that matches any HTTP PUT request

putshared default 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

putWithRegexshared default 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

routeshared default Route route()

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

routeshared default Route route(String path)

Add a route that matches the specified path

Parameters:
  • path

    URI paths that begin with this path will match

routeshared default 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

routeWithRegexshared default 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

routeWithRegexshared default 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

traceshared default Route trace()

Add a route that matches any HTTP TRACE request

traceshared default 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

traceWithRegexshared default 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

Inherited Methods
Methods inherited from: Object
equals