A router receives request from an io.vertx.groovy.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.
| 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(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 |
Object |
getDelegate() |
List<Route> |
getRoutes()@return
|
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. it matches all requests or failures. |
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 |
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 |
static Router |
router(Vertx vertx)Create a router |
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 |
This method is used to provide a request to the router. Usually you take request from the io.vertx.groovy.core.http.HttpServer#requestHandler and pass it to this method. The router then routes it to matching routes.
request - the requestRemove all the routes from this router
Add a route that matches any HTTP CONNECT request
Add a route that matches a HTTP CONNECT request and the specified path
path - URI paths that begin with this path will matchAdd a route that matches a HTTP CONNECT request and the specified path regex
regex - URI paths that begin with a match for this regex will matchAdd a route that matches any HTTP DELETE request
Add a route that matches a HTTP DELETE request and the specified path
path - URI paths that begin with this path will matchAdd a route that matches a HTTP DELETE request and the specified path regex
regex - URI paths that begin with a match for this regex will matchSpecify 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.
exceptionHandler - the exception handlerAdd a route that matches any HTTP GET request
Add a route that matches a HTTP GET request and the specified path
path - URI paths that begin with this path will matchAdd a route that matches a HTTP GET request and the specified path regex
regex - URI paths that begin with a match for this regex will matchUsed to route a context to the router. Used for sub-routers. You wouldn't normally call this method directly.
context - the routing contextUsed to route a failure to the router. Used for sub-routers. You wouldn't normally call this method directly.
context - the routing contextAdd a route that matches any HTTP HEAD request
Add a route that matches a HTTP HEAD request and the specified path
path - URI paths that begin with this path will matchAdd a route that matches a HTTP HEAD request and the specified path regex
regex - URI paths that begin with a match for this regex will matchMount a sub router on this router
mountPoint - the mount point (path prefix) to mount it onsubRouter - the router to mount as a sub routerAdd a route that matches any HTTP OPTIONS request
Add a route that matches a HTTP OPTIONS request and the specified path
path - URI paths that begin with this path will matchAdd a route that matches a HTTP OPTIONS request and the specified path regex
regex - URI paths that begin with a match for this regex will matchAdd a route that matches any HTTP PATCH request
Add a route that matches a HTTP PATCH request and the specified path
path - URI paths that begin with this path will matchAdd a route that matches a HTTP PATCH request and the specified path regex
regex - URI paths that begin with a match for this regex will matchAdd a route that matches any HTTP POST request
Add a route that matches a HTTP POST request and the specified path
path - URI paths that begin with this path will matchAdd a route that matches a HTTP POST request and the specified path regex
regex - URI paths that begin with a match for this regex will matchAdd a route that matches any HTTP PUT request
Add a route that matches a HTTP PUT request and the specified path
path - URI paths that begin with this path will matchAdd a route that matches a HTTP PUT request and the specified path regex
regex - URI paths that begin with a match for this regex will matchAdd a route with no matching criteria, i.e. it matches all requests or failures.
Add a route that matches the specified HTTP method and path
method - the HTTP method to matchpath - URI paths that begin with this path will matchAdd a route that matches the specified path
path - URI paths that begin with this path will matchAdd a route that matches the specified HTTP method and path regex
method - the HTTP method to matchregex - URI paths that begin with a match for this regex will matchAdd a route that matches the specified path regex
regex - URI paths that begin with a match for this regex will matchCreate a router
vertx - the Vert.x instanceAdd a route that matches any HTTP TRACE request
Add a route that matches a HTTP TRACE request and the specified path
path - URI paths that begin with this path will matchio.vertx:vertx-web:3.1.0