API / Minn\Http / Route

Route final readonly class

Minn\Http\Route · public/minn/src/Minn/Http/Route.php · 75 lines

Declares a handler method as a route. The policy lives here, as metadata the router enforces before the handler runs, so the authorization surface of the engine is a grep away; a route with no policy is one the ratchet in the style suite counts down. The parameter sets it reads live here too, judged before the policy is (the reference refuses a bad argument before it refuses a caller), so the REST index can tell a client what a route takes as well as what it requires of them.

Patterns: "/wp/v2/posts/{id}" captures one segment, "{id:\d+}" constrains it, and "/{path*}" captures the rest of the path (slashes included).

Constants and properties

propreadonly Minn\Http\Method $method

Promoted from the constructor.

propreadonly string $pattern

Promoted from the constructor.

propreadonly ?Minn\Http\Policy $policy

Promoted from the constructor.

propreadonly array $args

Promoted from the constructor.

propreadonly bool $index

Promoted from the constructor.

propreadonly array $body

Promoted from the constructor.

propreadonly ?string $name

Promoted from the constructor.

propreadonly ?string $params

Promoted from the constructor.

propreadonly ?string $refuse

Promoted from the constructor.

Public

new__construct(Minn\Http\Method $method, string $pattern, ?Minn\Http\Policy $policy = NULL, array $args = array ( ), bool $index = true, array $body = array ( ), ?string $name = NULL, ?string $params = NULL, ?string $refuse = NULL)#
$argslist<array<string, array<string, mixed>>>the parameter sets this route reads, from Args
$indexboolwhether the route is listed in the REST index (a route the index spells itself is not)
$bodylist<array<string, array<string, mixed>>>the parameter sets this route reads from the JSON body, from Args or the shape that owns them
$namestring|nullthe route's name in the catalogue; the handler's Class::method when null
$paramsclass-string<RouteParams>|nullthe parameters' source when they depend on the captures; $args otherwise
$refuseclass-string<Refusal>|nulla refusal judged after the arguments and before the policy
methodarguments(array $captures = array ( )): array#

The parameters this route accepts, as the REST index publishes them: from its params source for these captures (a capture the pattern fixes, such as {base:posts}, counts when none is given), or its fixed sets.

$capturesarray<string, string>
@return array<string, array<string, mixed>>
methodbodyArguments(): array#

The parameters this route reads from the JSON body, validated before the caller is judged.

@return array<string, array<string, mixed>>
methodregex(): string#

The pattern as a regular expression with named captures.