public class Router extends Object implements Handler<HttpServerRequest>
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.
NOTE: This class has been automatically generated from theoriginal
non RX-ified interface using Vert.x codegen.Modifier and Type | Field and Description |
---|---|
static io.vertx.lang.rx.TypeArg<Router> |
__TYPE_ARG |
Constructor and Description |
---|
Router(Object delegate) |
Router(Router delegate) |
Modifier and Type | Method and Description |
---|---|
void |
accept(HttpServerRequest request)
Deprecated.
|
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
|
boolean |
equals(Object o) |
Router |
errorHandler(int statusCode,
Handler<RoutingContext> errorHandler)
Specify an handler to handle an error for a particular status code.
|
Router |
exceptionHandler(Handler<Throwable> exceptionHandler)
Deprecated.
|
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
|
Router |
getDelegate() |
List<Route> |
getRoutes() |
Route |
getWithRegex(String regex)
Add a route that matches a HTTP GET request and the specified path regex
|
void |
handle(HttpServerRequest event)
Something has happened, so handle it.
|
void |
handleContext(RoutingContext context)
Used to route a context to the router.
|
void |
handleFailure(RoutingContext context)
Used to route a failure to the router.
|
int |
hashCode() |
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 |
modifiedHandler(Handler<Router> handler)
When a Router routes are changed this handler is notified.
|
Router |
mountSubRouter(String mountPoint,
Router subRouter)
Mount a sub router on this router
|
static Router |
newInstance(Router arg) |
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.
|
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
|
static Router |
router(Vertx vertx)
Create a router
|
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
|
String |
toString() |
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
|
public static final io.vertx.lang.rx.TypeArg<Router> __TYPE_ARG
public Router getDelegate()
public void handle(HttpServerRequest event)
handle
in interface Handler<HttpServerRequest>
event
- the event to handlepublic static Router router(Vertx vertx)
vertx
- the Vert.x instance@Deprecated public void accept(HttpServerRequest request)
HttpServer.requestHandler(io.vertx.core.Handler<io.vertx.rxjava.core.http.HttpServerRequest>)
and pass it to this method. The
router then routes it to matching routes.
This method is now deprecated you can use this object directly as a request handler, which
means there is no need for a method reference anymore.request
- the requestpublic Route route()
public Route route(HttpMethod method, String path)
method
- the HTTP method to matchpath
- URI paths that begin with this path will matchpublic Route route(String path)
path
- URI paths that begin with this path will matchpublic Route routeWithRegex(HttpMethod method, String regex)
method
- the HTTP method to matchregex
- URI paths that begin with a match for this regex will matchpublic Route routeWithRegex(String regex)
regex
- URI paths that begin with a match for this regex will matchpublic Route get()
public Route get(String path)
path
- URI paths that begin with this path will matchpublic Route getWithRegex(String regex)
regex
- URI paths that begin with a match for this regex will matchpublic Route head()
public Route head(String path)
path
- URI paths that begin with this path will matchpublic Route headWithRegex(String regex)
regex
- URI paths that begin with a match for this regex will matchpublic Route options()
public Route options(String path)
path
- URI paths that begin with this path will matchpublic Route optionsWithRegex(String regex)
regex
- URI paths that begin with a match for this regex will matchpublic Route put()
public Route put(String path)
path
- URI paths that begin with this path will matchpublic Route putWithRegex(String regex)
regex
- URI paths that begin with a match for this regex will matchpublic Route post()
public Route post(String path)
path
- URI paths that begin with this path will matchpublic Route postWithRegex(String regex)
regex
- URI paths that begin with a match for this regex will matchpublic Route delete()
public Route delete(String path)
path
- URI paths that begin with this path will matchpublic Route deleteWithRegex(String regex)
regex
- URI paths that begin with a match for this regex will matchpublic Route trace()
public Route trace(String path)
path
- URI paths that begin with this path will matchpublic Route traceWithRegex(String regex)
regex
- URI paths that begin with a match for this regex will matchpublic Route connect()
public Route connect(String path)
path
- URI paths that begin with this path will matchpublic Route connectWithRegex(String regex)
regex
- URI paths that begin with a match for this regex will matchpublic Route patch()
public Route patch(String path)
path
- URI paths that begin with this path will matchpublic Route patchWithRegex(String regex)
regex
- URI paths that begin with a match for this regex will matchpublic Router clear()
public Router mountSubRouter(String mountPoint, Router subRouter)
mountPoint
- the mount point (path prefix) to mount it onsubRouter
- the router to mount as a sub router@Deprecated public Router exceptionHandler(Handler<Throwable> exceptionHandler)
exceptionHandler
- the exception handlerpublic Router errorHandler(int statusCode, Handler<RoutingContext> errorHandler)
RoutingContext.next()
inside the error handler
This does not affect the normal failure routing logic.statusCode
- status code the errorHandler is capable of handleerrorHandler
- error handler. Note: You must not use RoutingContext.next()
inside the provided handlerpublic void handleContext(RoutingContext context)
context
- the routing contextpublic void handleFailure(RoutingContext context)
context
- the routing contextpublic Router modifiedHandler(Handler<Router> handler)
handler
- a notification handler that will receive this router as argumentCopyright © 2023 Eclipse. All rights reserved.