Documentation

RewriteRule
in package

A route is a class that rewrites a URL path (route) that matches a route or pattern (old_route) into a new route that the system can use (new_route) to handle the current request.

A Route will only accept Closures, Responses or Paths (including arrays that can be interpreted as Paths by the translation class) as the target.

Tags
todo

Define translate class for array to Path translation

todo

Define parameter class to replace inside Paths

author

César de la Cal cesar@magic3w.com

Table of Contents

METHOD_DELETE  = 0x8
METHOD_GET  = 0x1
METHOD_HEAD  = 0x10
METHOD_OPTIONS  = 0x20
METHOD_POST  = 0x2
METHOD_PUT  = 0x4
PROTO_ANY  = 0x3
PROTO_HTTP  = 0x1
PROTO_HTTPS  = 0x2
$method  : mixed
$newRoute  : RequestHandlerInterface
$pattern  : URIPattern
__construct()  : mixed
A route is a pattern Spitfire uses to redirect an URL to something else.
getSource()  : URIPattern
getTarget()  : RequestHandlerInterface
rewrite()  : Parameters|null
test()  : mixed
testMethod()  : bool
Checks whether a certain method applies to this route. The route can accept as many protocols as it wants. The protocols are converted to hex integers and are AND'd to check whether the selected protocol is included in the list of admitted ones.
testProto()  : bool
Tests whether the requested protocol (HTTPS or not) is accepted by this route. We use once again binary masks to test the protocol. This means that we can either use HTTP (01), HTTPS (10) or both (11) which will translate into an integer 1, 2 and 3.

Constants

Properties

Methods

__construct()

A route is a pattern Spitfire uses to redirect an URL to something else.

public __construct(URIPattern $pattern, RequestHandlerInterface $new_route, string $method[, int $proto = Route::PROTO_ANY ]) : mixed

It can 'redirect' (without it being a 302) a request to a new URL, it can directly send back a response or assign a custom controller, action and object to the request.

Parameters
$pattern : URIPattern
$new_route : RequestHandlerInterface
$method : string
$proto : int = Route::PROTO_ANY
Return values
mixed

getTarget()

public getTarget() : RequestHandlerInterface
Return values
RequestHandlerInterface

rewrite()

public abstract rewrite(ServerRequestInterface $request) : Parameters|null
Parameters
$request : ServerRequestInterface
Return values
Parameters|null

test()

public test(mixed $URI, mixed $method) : mixed
Parameters
$URI : mixed
$method : mixed
Return values
mixed

testMethod()

Checks whether a certain method applies to this route. The route can accept as many protocols as it wants. The protocols are converted to hex integers and are AND'd to check whether the selected protocol is included in the list of admitted ones.

public testMethod(string|int $method) : bool
Parameters
$method : string|int
Return values
bool

testProto()

Tests whether the requested protocol (HTTPS or not) is accepted by this route. We use once again binary masks to test the protocol. This means that we can either use HTTP (01), HTTPS (10) or both (11) which will translate into an integer 1, 2 and 3.

public testProto(bool $protocol) : bool

This way the user can quickly decide whether he wants to use any or both of them to match a route.

Parameters
$protocol : bool
Tags
deprecated

We're letting the web server care about https

Return values
bool

Search results