Class: Router

vertx-web-js/router~ Router

new Router()

Source:

Methods

accept(request)

This method is used to provide a request to the router. Usually you take request from the HttpServer#requestHandler 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.
Parameters:
Name Type Description
request HttpServerRequest the request
Source:

clear() → {Router}

Remove all the routes from this router
Source:
Returns:
a reference to this, so the API can be used fluently
Type
Router

connect(path) → {Route}

Add a route that matches a HTTP CONNECT request and the specified path
Parameters:
Name Type Description
path string URI paths that begin with this path will match
Source:
Returns:
the route
Type
Route

connectWithRegex(regex) → {Route}

Add a route that matches a HTTP CONNECT request and the specified path regex
Parameters:
Name Type Description
regex string URI paths that begin with a match for this regex will match
Source:
Returns:
the route
Type
Route

delete(path) → {Route}

Add a route that matches a HTTP DELETE request and the specified path
Parameters:
Name Type Description
path string URI paths that begin with this path will match
Source:
Returns:
the route
Type
Route

deleteWithRegex(regex) → {Route}

Add a route that matches a HTTP DELETE request and the specified path regex
Parameters:
Name Type Description
regex string URI paths that begin with a match for this regex will match
Source:
Returns:
the route
Type
Route

errorHandler(statusCode, errorHandler) → {Router}

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 use RoutingContext#next inside the error handler This does not affect the normal failure routing logic.
Parameters:
Name Type Description
statusCode number status code the errorHandler is capable of handle
errorHandler function error handler. Note: You must not use RoutingContext#next inside the provided handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
Router

exceptionHandler(exceptionHandler) → {Router}

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:
Name Type Description
exceptionHandler function the exception handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
Router

get(path) → {Route}

Add a route that matches a HTTP GET request and the specified path
Parameters:
Name Type Description
path string URI paths that begin with this path will match
Source:
Returns:
the route
Type
Route

getRoutes() → {Array.<Route>}

Source:
Returns:
a list of all the routes on this router
Type
Array.<Route>

getWithRegex(regex) → {Route}

Add a route that matches a HTTP GET request and the specified path regex
Parameters:
Name Type Description
regex string URI paths that begin with a match for this regex will match
Source:
Returns:
the route
Type
Route

handle(event)

Something has happened, so handle it.
Parameters:
Name Type Description
event HttpServerRequest the event to handle
Source:

handleContext(context)

Used to route a context to the router. Used for sub-routers. You wouldn't normally call this method directly.
Parameters:
Name Type Description
context RoutingContext the routing context
Source:

handleFailure(context)

Used to route a failure to the router. Used for sub-routers. You wouldn't normally call this method directly.
Parameters:
Name Type Description
context RoutingContext the routing context
Source:
Add a route that matches a HTTP HEAD request and the specified path
Parameters:
Name Type Description
path string URI paths that begin with this path will match
Source:
Returns:
the route
Type
Route

headWithRegex(regex) → {Route}

Add a route that matches a HTTP HEAD request and the specified path regex
Parameters:
Name Type Description
regex string URI paths that begin with a match for this regex will match
Source:
Returns:
the route
Type
Route

mountSubRouter(mountPoint, subRouter) → {Router}

Mount a sub router on this router
Parameters:
Name Type Description
mountPoint string the mount point (path prefix) to mount it on
subRouter Router the router to mount as a sub router
Source:
Returns:
a reference to this, so the API can be used fluently
Type
Router

options(path) → {Route}

Add a route that matches a HTTP OPTIONS request and the specified path
Parameters:
Name Type Description
path string URI paths that begin with this path will match
Source:
Returns:
the route
Type
Route

optionsWithRegex(regex) → {Route}

Add a route that matches a HTTP OPTIONS request and the specified path regex
Parameters:
Name Type Description
regex string URI paths that begin with a match for this regex will match
Source:
Returns:
the route
Type
Route

patch(path) → {Route}

Add a route that matches a HTTP PATCH request and the specified path
Parameters:
Name Type Description
path string URI paths that begin with this path will match
Source:
Returns:
the route
Type
Route

patchWithRegex(regex) → {Route}

Add a route that matches a HTTP PATCH request and the specified path regex
Parameters:
Name Type Description
regex string URI paths that begin with a match for this regex will match
Source:
Returns:
the route
Type
Route

post(path) → {Route}

Add a route that matches a HTTP POST request and the specified path
Parameters:
Name Type Description
path string URI paths that begin with this path will match
Source:
Returns:
the route
Type
Route

postWithRegex(regex) → {Route}

Add a route that matches a HTTP POST request and the specified path regex
Parameters:
Name Type Description
regex string URI paths that begin with a match for this regex will match
Source:
Returns:
the route
Type
Route

put(path) → {Route}

Add a route that matches a HTTP PUT request and the specified path
Parameters:
Name Type Description
path string URI paths that begin with this path will match
Source:
Returns:
the route
Type
Route

putWithRegex(regex) → {Route}

Add a route that matches a HTTP PUT request and the specified path regex
Parameters:
Name Type Description
regex string URI paths that begin with a match for this regex will match
Source:
Returns:
the route
Type
Route

route(path) → {Route}

Add a route that matches the specified path
Parameters:
Name Type Description
path string URI paths that begin with this path will match
Source:
Returns:
the route
Type
Route

routeWithRegex(regex) → {Route}

Add a route that matches the specified path regex
Parameters:
Name Type Description
regex string URI paths that begin with a match for this regex will match
Source:
Returns:
the route
Type
Route

trace(path) → {Route}

Add a route that matches a HTTP TRACE request and the specified path
Parameters:
Name Type Description
path string URI paths that begin with this path will match
Source:
Returns:
the route
Type
Route

traceWithRegex(regex) → {Route}

Add a route that matches a HTTP TRACE request and the specified path regex
Parameters:
Name Type Description
regex string URI paths that begin with a match for this regex will match
Source:
Returns:
the route
Type
Route