Router

A router receives request from an @see \io\vertx\jphp\core\http\HttpServer and routes it to the first matching

see

that it contains. A router can contain many routes.

Routers are also used for routing failures.

package

Default

Methods

__construct

__construct() 

This method is used to provide a request to the router. Usually you take request from the

accept( $arg0) : void
see \io\vertx\jphp\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.

deprecated

Arguments

$arg0

HttpServerRequest

Remove all the routes from this router

clear() : $this

Response

$this

a reference to this, so the API can be used fluently

Add a route that matches any HTTP CONNECT request

connect( $arg0 = null) : \io\vertx\jphp\ext\web\Route

connect()

Add a route that matches a HTTP CONNECT request and the specified path

param $path [string] URI paths that begin with this path will match connect($path)

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches a HTTP CONNECT request and the specified path regex

connectWithRegex( $arg0) : \io\vertx\jphp\ext\web\Route

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches any HTTP DELETE request

delete( $arg0 = null) : \io\vertx\jphp\ext\web\Route

delete()

Add a route that matches a HTTP DELETE request and the specified path

param $path [string] URI paths that begin with this path will match delete($path)

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches a HTTP DELETE request and the specified path regex

deleteWithRegex( $arg0) : \io\vertx\jphp\ext\web\Route

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

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.

exceptionHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

a reference to this, so the API can be used fluently

Add a route that matches any HTTP GET request

get( $arg0 = null) : \io\vertx\jphp\ext\web\Route

get()

Add a route that matches a HTTP GET request and the specified path

param $path [string] URI paths that begin with this path will match get($path)

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

getRoutes

getRoutes() : array

Response

array

a list of all the routes on this router

Add a route that matches a HTTP GET request and the specified path regex

getWithRegex( $arg0) : \io\vertx\jphp\ext\web\Route

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Something has happened, so handle it.

handle( $arg0) : void

Arguments

$arg0

HttpServerRequest

Used to route a context to the router. Used for sub-routers. You wouldn't normally call this method directly.

handleContext( $arg0) : void

Arguments

$arg0

RoutingContext

Used to route a failure to the router. Used for sub-routers. You wouldn't normally call this method directly.

handleFailure( $arg0) : void

Arguments

$arg0

RoutingContext

Add a route that matches any HTTP HEAD request

head( $arg0 = null) : \io\vertx\jphp\ext\web\Route

head()

Add a route that matches a HTTP HEAD request and the specified path

param $path [string] URI paths that begin with this path will match head($path)

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches a HTTP HEAD request and the specified path regex

headWithRegex( $arg0) : \io\vertx\jphp\ext\web\Route

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Mount a sub router on this router

mountSubRouter( $arg0,  $arg1) : $this

Arguments

$arg0

string

$arg1

Router

Response

$this

a reference to this, so the API can be used fluently

Add a route that matches any HTTP OPTIONS request

options( $arg0 = null) : \io\vertx\jphp\ext\web\Route

options()

Add a route that matches a HTTP OPTIONS request and the specified path

param $path [string] URI paths that begin with this path will match options($path)

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches a HTTP OPTIONS request and the specified path regex

optionsWithRegex( $arg0) : \io\vertx\jphp\ext\web\Route

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches any HTTP PATCH request

patch( $arg0 = null) : \io\vertx\jphp\ext\web\Route

patch()

Add a route that matches a HTTP PATCH request and the specified path

param $path [string] URI paths that begin with this path will match patch($path)

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches a HTTP PATCH request and the specified path regex

patchWithRegex( $arg0) : \io\vertx\jphp\ext\web\Route

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches any HTTP POST request

post( $arg0 = null) : \io\vertx\jphp\ext\web\Route

post()

Add a route that matches a HTTP POST request and the specified path

param $path [string] URI paths that begin with this path will match post($path)

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches a HTTP POST request and the specified path regex

postWithRegex( $arg0) : \io\vertx\jphp\ext\web\Route

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches any HTTP PUT request

put( $arg0 = null) : \io\vertx\jphp\ext\web\Route

put()

Add a route that matches a HTTP PUT request and the specified path

param $path [string] URI paths that begin with this path will match put($path)

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches a HTTP PUT request and the specified path regex

putWithRegex( $arg0) : \io\vertx\jphp\ext\web\Route

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route with no matching criteria, i.e. it matches all requests or failures.

route( $arg0 = null,  $arg1 = null) : \io\vertx\jphp\ext\web\Route

route()

Add a route that matches the specified path

param $path [string] URI paths that begin with this path will match route($path)

Add a route that matches the specified HTTP method and path

param $method [string] the HTTP method to match param $path [string] URI paths that begin with this path will match route($method, $path)

Arguments

$arg0

string

$arg1

string

Response

\io\vertx\jphp\ext\web\Route

the route

Create a router

router( $arg0) : \io\vertx\jphp\ext\web\Router
static

Arguments

$arg0

Vertx

Response

\io\vertx\jphp\ext\web\Router

the router

Add a route that matches the specified path regex

routeWithRegex( $arg0,  $arg1 = null) : \io\vertx\jphp\ext\web\Route

param $regex [string] URI paths that begin with a match for this regex will match routeWithRegex($regex)

Add a route that matches the specified HTTP method and path regex

param $method [string] the HTTP method to match param $regex [string] URI paths that begin with a match for this regex will match routeWithRegex($method, $regex)

Arguments

$arg0

string

$arg1

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches any HTTP TRACE request

trace( $arg0 = null) : \io\vertx\jphp\ext\web\Route

trace()

Add a route that matches a HTTP TRACE request and the specified path

param $path [string] URI paths that begin with this path will match trace($path)

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route

Add a route that matches a HTTP TRACE request and the specified path regex

traceWithRegex( $arg0) : \io\vertx\jphp\ext\web\Route

Arguments

$arg0

string

Response

\io\vertx\jphp\ext\web\Route

the route