Package io.vertx.reactivex.ext.web
Class Router
- java.lang.Object
- 
- io.vertx.reactivex.ext.web.Router
 
- 
- All Implemented Interfaces:
- Handler<HttpServerRequest>,- io.vertx.lang.rx.RxDelegate
 
 public class Router extends Object implements io.vertx.lang.rx.RxDelegate, Handler<HttpServerRequest> A router receives request from anHttpServerand routes it to the first matchingRoutethat it contains. A router can contain many routes.Routers are also used for routing failures. NOTE: This class has been automatically generated from the originalnon RX-ified interface using Vert.x codegen.
- 
- 
Field SummaryFields Modifier and Type Field Description static io.vertx.lang.rx.TypeArg<Router>__TYPE_ARG
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RouterallowForward(AllowForwardHeaders allowForwardHeaders)Set whether the router should parse "forwarded"-type headersRouterclear()Remove all the routes from this routerRouteconnect()Add a route that matches any HTTP CONNECT requestRouteconnect(String path)Add a route that matches a HTTP CONNECT request and the specified pathRouteconnectWithRegex(String regex)Add a route that matches a HTTP CONNECT request and the specified path regexRoutedelete()Add a route that matches any HTTP DELETE requestRoutedelete(String path)Add a route that matches a HTTP DELETE request and the specified pathRoutedeleteWithRegex(String regex)Add a route that matches a HTTP DELETE request and the specified path regexbooleanequals(Object o)RoutererrorHandler(int statusCode, Handler<RoutingContext> errorHandler)Specify an handler to handle an error for a particular status code.Routeget()Add a route that matches any HTTP GET requestRouteget(String path)Add a route that matches a HTTP GET request and the specified pathRoutergetDelegate()<T> TgetMetadata(String key)Get some data from metadata.List<Route>getRoutes()RoutegetWithRegex(String regex)Add a route that matches a HTTP GET request and the specified path regexvoidhandle(HttpServerRequest event)Something has happened, so handle it.voidhandleContext(RoutingContext context)Used to route a context to the router.voidhandleFailure(RoutingContext context)Used to route a failure to the router.inthashCode()Routehead()Add a route that matches any HTTP HEAD requestRoutehead(String path)Add a route that matches a HTTP HEAD request and the specified pathRouteheadWithRegex(String regex)Add a route that matches a HTTP HEAD request and the specified path regexMap<String,Object>metadata()RoutermodifiedHandler(Handler<Router> handler)When a Router routes are changed this handler is notified.static RouternewInstance(Router arg)Routeoptions()Add a route that matches any HTTP OPTIONS requestRouteoptions(String path)Add a route that matches a HTTP OPTIONS request and the specified pathRouteoptionsWithRegex(String regex)Add a route that matches a HTTP OPTIONS request and the specified path regexRoutepatch()Add a route that matches any HTTP PATCH requestRoutepatch(String path)Add a route that matches a HTTP PATCH request and the specified pathRoutepatchWithRegex(String regex)Add a route that matches a HTTP PATCH request and the specified path regexRoutepost()Add a route that matches any HTTP POST requestRoutepost(String path)Add a route that matches a HTTP POST request and the specified pathRoutepostWithRegex(String regex)Add a route that matches a HTTP POST request and the specified path regexRouteput()Add a route that matches any HTTP PUT requestRouteput(String path)Add a route that matches a HTTP PUT request and the specified pathRouterputMetadata(String key, Object value)Put metadata to this router.RouteputWithRegex(String regex)Add a route that matches a HTTP PUT request and the specified path regexRouteroute()Add a route with no matching criteria, i.e. it matches all requests or failures.Routeroute(HttpMethod method, String path)Add a route that matches the specified HTTP method and pathRouteroute(String path)Add a route that matches the specified pathstatic Routerrouter(Vertx vertx)Create a routerRouterouteWithRegex(HttpMethod method, String regex)Add a route that matches the specified HTTP method and path regexRouterouteWithRegex(String regex)Add a route that matches the specified path regexStringtoString()Routetrace()Add a route that matches any HTTP TRACE requestRoutetrace(String path)Add a route that matches a HTTP TRACE request and the specified pathRoutetraceWithRegex(String regex)Add a route that matches a HTTP TRACE request and the specified path regex
 
- 
- 
- 
Field Detail- 
__TYPE_ARGpublic static final io.vertx.lang.rx.TypeArg<Router> __TYPE_ARG 
 
- 
 - 
Method Detail- 
getDelegatepublic Router getDelegate() - Specified by:
- getDelegatein interface- io.vertx.lang.rx.RxDelegate
 
 - 
handlepublic void handle(HttpServerRequest event) Something has happened, so handle it.- Specified by:
- handlein interface- Handler<HttpServerRequest>
- Parameters:
- event- the event to handle
 
 - 
putMetadatapublic Router putMetadata(String key, Object value) Put metadata to this router. 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
 
 - 
metadatapublic Map<String,Object> metadata() - Returns:
- the metadata of this router, never returns null.
 
 - 
getMetadatapublic <T> T getMetadata(String key) Get some data from metadata.- Parameters:
- key- the key for the metadata
- Returns:
- the data
 
 - 
routerpublic static Router router(Vertx vertx) Create a router- Parameters:
- vertx- the Vert.x instance
- Returns:
- the router
 
 - 
routepublic Route route() Add a route with no matching criteria, i.e. it matches all requests or failures.- Returns:
- the route
 
 - 
routepublic 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
- Returns:
- the route
 
 - 
routepublic Route route(String path) Add a route that matches the specified path- Parameters:
- path- URI paths that begin with this path will match
- Returns:
- the route
 
 - 
routeWithRegexpublic 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
- Returns:
- the route
 
 - 
routeWithRegexpublic 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
- Returns:
- the route
 
 - 
getpublic Route get() Add a route that matches any HTTP GET request- Returns:
- the route
 
 - 
getpublic 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
- Returns:
- the route
 
 - 
getWithRegexpublic 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
- Returns:
- the route
 
 - 
headpublic Route head() Add a route that matches any HTTP HEAD request- Returns:
- the route
 
 - 
headpublic 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
- Returns:
- the route
 
 - 
headWithRegexpublic 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
- Returns:
- the route
 
 - 
optionspublic Route options() Add a route that matches any HTTP OPTIONS request- Returns:
- the route
 
 - 
optionspublic 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
- Returns:
- the route
 
 - 
optionsWithRegexpublic 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
- Returns:
- the route
 
 - 
putpublic Route put() Add a route that matches any HTTP PUT request- Returns:
- the route
 
 - 
putpublic 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
- Returns:
- the route
 
 - 
putWithRegexpublic 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
- Returns:
- the route
 
 - 
postpublic Route post() Add a route that matches any HTTP POST request- Returns:
- the route
 
 - 
postpublic 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
- Returns:
- the route
 
 - 
postWithRegexpublic 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
- Returns:
- the route
 
 - 
deletepublic Route delete() Add a route that matches any HTTP DELETE request- Returns:
- the route
 
 - 
deletepublic 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
- Returns:
- the route
 
 - 
deleteWithRegexpublic 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
- Returns:
- the route
 
 - 
tracepublic Route trace() Add a route that matches any HTTP TRACE request- Returns:
- the route
 
 - 
tracepublic 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
- Returns:
- the route
 
 - 
traceWithRegexpublic 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
- Returns:
- the route
 
 - 
connectpublic Route connect() Add a route that matches any HTTP CONNECT request- Returns:
- the route
 
 - 
connectpublic 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
- Returns:
- the route
 
 - 
connectWithRegexpublic 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
- Returns:
- the route
 
 - 
patchpublic Route patch() Add a route that matches any HTTP PATCH request- Returns:
- the route
 
 - 
patchpublic 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
- Returns:
- the route
 
 - 
patchWithRegexpublic 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
- Returns:
- the route
 
 - 
clearpublic Router clear() Remove all the routes from this router- Returns:
- a reference to this, so the API can be used fluently
 
 - 
errorHandlerpublic Router errorHandler(int statusCode, Handler<RoutingContext> errorHandler) Specify an handler to handle an error for a particular status code. You can use to manage general errors too using status code 500. The handler will be called when the context fails and other failure handlers didn't write the reply or when an exception is thrown inside an handler. You must not useRoutingContext.next()inside the error handler This does not affect the normal failure routing logic.- Parameters:
- statusCode- status code the errorHandler is capable of handle
- errorHandler- error handler. Note: You must not use- RoutingContext.next()inside the provided handler
- Returns:
- a reference to this, so the API can be used fluently
 
 - 
handleContextpublic 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
 
 - 
handleFailurepublic 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
 
 - 
modifiedHandlerpublic Router modifiedHandler(Handler<Router> handler) When a Router routes are changed this handler is notified. This is useful for routes that depend on the state of the router.- Parameters:
- handler- a notification handler that will receive this router as argument
- Returns:
- a reference to this, so the API can be used fluently
 
 - 
allowForwardpublic Router allowForward(AllowForwardHeaders allowForwardHeaders) Set whether the router should parse "forwarded"-type headers- Parameters:
- allowForwardHeaders- to enable parsing of "forwarded"-type headers
- Returns:
- a reference to this, so the API can be used fluently
 
 
- 
 
-