-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMiddlewarePipelineInterface.php
More file actions
55 lines (51 loc) · 1.89 KB
/
Copy pathMiddlewarePipelineInterface.php
File metadata and controls
55 lines (51 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
declare(strict_types=1);
namespace HttpSoft\Runner;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
interface MiddlewarePipelineInterface extends MiddlewareInterface, RequestHandlerInterface
{
/**
* Adds middleware to the pipeline.
*
* By specifying the path prefix, the middleware is attached to the specific path
* and will only be processed if the request URI path starts with the given prefix.
*
* One middleware can be attached to different paths:
*
* ```php
* $pipeline->pipe($authMiddleware, '/blog');
* $pipeline->pipe($authMiddleware, '/forum');
* ```
*
* Multiple intermediate programs can be connected to the same path:
*
* ```php
* $pipeline->pipe($authMiddleware, '/admin');
* $pipeline->pipe($adminMiddleware, '/admin');
* ```
*
* The path prefix MUST start at the root, and the leading and
* trailing slashes are optional ("/path" or "path" or "path/").
*
* ```php
* // Available: `https://example.com` and `https://example.com/any`:
* $pipeline->pipe($commonMiddleware);
* // Or
* $pipeline->pipe($commonMiddleware, '');
* // Or
* $pipeline->pipe($commonMiddleware, '/');
*
* // Available: `https://example.com/api` and `https://example.com/api/any`:
* $pipeline->pipe($apiMiddleware, '/api');
*
* // Available: `https://example.com/api/admin` and `https://example.com/api/admin/any`:
* $pipeline->pipe($apiAdminMiddleware, '/api/admin');
* // but not available: `https://example.com/api` and `https://example.com/api/any`.
* ```
*
* @param MiddlewareInterface $middleware
* @param string|null $pathPrefix path prefix from the root to which the middleware is attached.
*/
public function pipe(MiddlewareInterface $middleware, ?string $pathPrefix = null): void;
}