-
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.
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
-
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:
-
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
-
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:
-
head(path) → {Route}
-
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(method, path) → {Route}
-
Add a route that matches the specified HTTP method and path
Parameters:
Name |
Type |
Description |
method |
Object
|
the HTTP method to match |
path |
string
|
URI paths that begin with this path will match |
- Source:
Returns:
the route
-
Type
-
Route
-
routeWithRegex(method, regex) → {Route}
-
Add a route that matches the specified HTTP method and path regex
Parameters:
Name |
Type |
Description |
method |
Object
|
the HTTP method to match |
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