Aerys\Router classRouter implementsAerys\Bootable, Aerys\Middleware, Aerys\Monitor, Aerys\ServerObserver

Summary

Properties

Methods

Properties

Methods

setOption —public functionsetOption(string$key,mixed$value)

Set a router option

Type Parameter Description Default Value
string $key No documentation. none
mixed $value No documentation. none
__invoke —public function__invoke(Aerys\Request$request,Aerys\Response$response)

Route a request

Type Parameter Description Default Value
Aerys\Request $request No documentation. none
Aerys\Response $response No documentation. none
do —public functiondo(Aerys\InternalRequest$ireq)

Execute router middleware functionality

Type Parameter Description Default Value
Aerys\InternalRequest $ireq No documentation. none
use —public functionuse(callable|Aerys\Middleware|Aerys\Bootable|Aerys\Monitor$action):self

Import a router or attach a callable, Middleware or Bootable.

Router imports do not import the options

Type Parameter Description Default Value
callable|Aerys\Middleware|Aerys\Bootable|Aerys\Monitor $action No documentation. none
prefix —public functionprefix(string$prefix):self

Prefix all the (already defined) routes with a given prefix

Type Parameter Description Default Value
string $prefix No documentation. none
__call —public function__call(string$method,array$args):self

Allow shortcut route registration using the called method name as the HTTP method verb

HTTP method verbs -- though case-sensitive -- are used in all-caps for most applications. Shortcut method verbs will automatically be changed to all-caps. Applications wishing to define case-sensitive methods should use Router::route() to specify the desired method directly.

Type Parameter Description Default Value
string $method No documentation. none
array $args No documentation. none
route —public functionroute(string$method,string$uri,Aerys\Bootable|Aerys\Middleware|Aerys\Monitor|callable...$actions):self

Define an application route

The variadic ...$actions argument allows applications to specify multiple separate handlers for a given route URI. When matched these action callables will be invoked in order until one starts a response. If the resulting action fails to send a response the end result is a 404.

Matched URI route arguments are made available to action callables as an array in the following Request property:

$request->locals->routeArgs array.

Route URIs ending in "/?" (without the quotes) allow a URI match with or without the trailing slash. Temporary redirects are used to redirect to the canonical URI (with a trailing slash) to avoid search engine duplicate content penalties.

Type Parameter Description Default Value
string $method The HTTP method verb for which this route applies none
string $uri The string URI none
Aerys\Bootable|Aerys\Middleware|Aerys\Monitor|callable ... $actions The action(s) to invoke upon matching this route none
boot —public functionboot(Aerys\Server$server,Aerys\Logger$logger)
No documentation.
Type Parameter Description Default Value
Aerys\Server $server No documentation. none
Aerys\Logger $logger No documentation. none
update —public functionupdate(Aerys\Server$server):Amp\Promise

React to server state changes

Here we generate our dispatcher when the server notifies us that it is ready to start (Server::STARTING).

Type Parameter Description Default Value
Aerys\Server $server No documentation. none
monitor —public functionmonitor():array
No documentation.