class Router extends Handler[HttpServerRequest]
A router receives request from an io.vertx.scala.core.http.HttpServer and routes it to the first matching io.vertx.scala.ext.web.Route that it contains. A router can contain many routes.
Routers are also used for routing failures.
- Alphabetic
- By Inheritance
- Router
- Handler
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Router(_asJava: AnyRef)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
accept(request: HttpServerRequest): Unit
This method is used to provide a request to the router.
This method is used to provide a request to the router. Usually you take request from the io.vertx.scala.core.http.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. * @param request the request
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- def asJava: AnyRef
-
def
clear(): Router
Remove all the routes from this router * @return a reference to this, so the API can be used fluently
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
connect(path: String): Route
Add a route that matches a HTTP CONNECT request and the specified path * @param path URI paths that begin with this path will match
Add a route that matches a HTTP CONNECT request and the specified path * @param path URI paths that begin with this path will match
- returns
the route
-
def
connect(): Route
Add a route that matches any HTTP CONNECT request * @return the route
-
def
connectWithRegex(regex: String): Route
Add a route that matches a HTTP CONNECT request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
Add a route that matches a HTTP CONNECT request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
- returns
the route
-
def
delete(path: String): Route
Add a route that matches a HTTP DELETE request and the specified path * @param path URI paths that begin with this path will match
Add a route that matches a HTTP DELETE request and the specified path * @param path URI paths that begin with this path will match
- returns
the route
-
def
delete(): Route
Add a route that matches any HTTP DELETE request * @return the route
-
def
deleteWithRegex(regex: String): Route
Add a route that matches a HTTP DELETE request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
Add a route that matches a HTTP DELETE request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
- returns
the route
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
errorHandler(statusCode: Int, errorHandler: Handler[RoutingContext]): Router
Specify an handler to handle an error for a particular status code.
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 io.vertx.scala.ext.web.RoutingContext#next inside the error handler This does not affect the normal failure routing logic. * @param 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
-
def
exceptionHandler(exceptionHandler: Handler[Throwable]): Router
Specify a handler for any unhandled exceptions on this 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. * @param exceptionHandler the exception handler
- returns
a reference to this, so the API can be used fluently
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
get(path: String): Route
Add a route that matches a HTTP GET request and the specified path * @param path URI paths that begin with this path will match
Add a route that matches a HTTP GET request and the specified path * @param path URI paths that begin with this path will match
- returns
the route
-
def
get(): Route
Add a route that matches any HTTP GET request * @return the route
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getRoutes(): Buffer[Route]
- returns
a list of all the routes on this router
-
def
getWithRegex(regex: String): Route
Add a route that matches a HTTP GET request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
Add a route that matches a HTTP GET request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
- returns
the route
-
def
handle(arg0: HttpServerRequest): Unit
- Definition Classes
- Router → Handler
-
def
handleContext(context: RoutingContext): Unit
Used to route a context to the router.
Used to route a context to the router. Used for sub-routers. You wouldn't normally call this method directly. * @param context the routing context
-
def
handleFailure(context: RoutingContext): Unit
Used to route a failure to the router.
Used to route a failure to the router. Used for sub-routers. You wouldn't normally call this method directly. * @param context the routing context
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
head(path: String): Route
Add a route that matches a HTTP HEAD request and the specified path * @param path URI paths that begin with this path will match
Add a route that matches a HTTP HEAD request and the specified path * @param path URI paths that begin with this path will match
- returns
the route
-
def
head(): Route
Add a route that matches any HTTP HEAD request * @return the route
-
def
headWithRegex(regex: String): Route
Add a route that matches a HTTP HEAD request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
Add a route that matches a HTTP HEAD request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
- returns
the route
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
mountSubRouter(mountPoint: String, subRouter: Router): Router
Mount a sub router on this router * @param mountPoint the mount point (path prefix) to mount it on
Mount a sub router on this router * @param mountPoint the mount point (path prefix) to mount it on
- subRouter
the router to mount as a sub router
- returns
a reference to this, so the API can be used fluently
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
options(path: String): Route
Add a route that matches a HTTP OPTIONS request and the specified path * @param path URI paths that begin with this path will match
Add a route that matches a HTTP OPTIONS request and the specified path * @param path URI paths that begin with this path will match
- returns
the route
-
def
options(): Route
Add a route that matches any HTTP OPTIONS request * @return the route
-
def
optionsWithRegex(regex: String): Route
Add a route that matches a HTTP OPTIONS request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
Add a route that matches a HTTP OPTIONS request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
- returns
the route
-
def
patch(path: String): Route
Add a route that matches a HTTP PATCH request and the specified path * @param path URI paths that begin with this path will match
Add a route that matches a HTTP PATCH request and the specified path * @param path URI paths that begin with this path will match
- returns
the route
-
def
patch(): Route
Add a route that matches any HTTP PATCH request * @return the route
-
def
patchWithRegex(regex: String): Route
Add a route that matches a HTTP PATCH request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
Add a route that matches a HTTP PATCH request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
- returns
the route
-
def
post(path: String): Route
Add a route that matches a HTTP POST request and the specified path * @param path URI paths that begin with this path will match
Add a route that matches a HTTP POST request and the specified path * @param path URI paths that begin with this path will match
- returns
the route
-
def
post(): Route
Add a route that matches any HTTP POST request * @return the route
-
def
postWithRegex(regex: String): Route
Add a route that matches a HTTP POST request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
Add a route that matches a HTTP POST request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
- returns
the route
-
def
put(path: String): Route
Add a route that matches a HTTP PUT request and the specified path * @param path URI paths that begin with this path will match
Add a route that matches a HTTP PUT request and the specified path * @param path URI paths that begin with this path will match
- returns
the route
-
def
put(): Route
Add a route that matches any HTTP PUT request * @return the route
-
def
putWithRegex(regex: String): Route
Add a route that matches a HTTP PUT request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
Add a route that matches a HTTP PUT request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
- returns
the route
-
def
route(path: String): Route
Add a route that matches the specified path * @param path URI paths that begin with this path will match
Add a route that matches the specified path * @param path URI paths that begin with this path will match
- returns
the route
-
def
route(method: HttpMethod, path: String): Route
Add a route that matches the specified HTTP method and path * @param method the HTTP method to match
Add a route that matches the specified HTTP method and path * @param method the HTTP method to match
- path
URI paths that begin with this path will match
- returns
the route
-
def
route(): Route
Add a route with no matching criteria, i.e.
Add a route with no matching criteria, i.e. it matches all requests or failures. * @return the route
-
def
routeWithRegex(regex: String): Route
Add a route that matches the specified path regex * @param regex URI paths that begin with a match for this regex will match
Add a route that matches the specified path regex * @param regex URI paths that begin with a match for this regex will match
- returns
the route
-
def
routeWithRegex(method: HttpMethod, regex: String): Route
Add a route that matches the specified HTTP method and path regex * @param method the HTTP method to match
Add a route that matches the specified HTTP method and path regex * @param method the HTTP method to match
- regex
URI paths that begin with a match for this regex will match
- returns
the route
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
trace(path: String): Route
Add a route that matches a HTTP TRACE request and the specified path * @param path URI paths that begin with this path will match
Add a route that matches a HTTP TRACE request and the specified path * @param path URI paths that begin with this path will match
- returns
the route
-
def
trace(): Route
Add a route that matches any HTTP TRACE request * @return the route
-
def
traceWithRegex(regex: String): Route
Add a route that matches a HTTP TRACE request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
Add a route that matches a HTTP TRACE request and the specified path regex * @param regex URI paths that begin with a match for this regex will match
- returns
the route
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )