Skip to content

Commit 1d60e54

Browse files
committed
Readme
1 parent fbfda4e commit 1d60e54

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,51 @@
1-
# double-pass-compatibility
1+
# double-pass-compatibility [![Build Status](https://travis-ci.org/php-middleware/double-pass-compatibility.svg?branch=master)](https://travis-ci.org/php-middleware/double-pass-compatibility)
2+
23
Tools for support double pass middewares in PSR-15
4+
5+
This package provide trait and abstract class for your [psr-15 middlewares](https://github.com/http-interop/http-middleware#42-single-pass-lambda) to [double pass middewares](https://github.com/http-interop/http-middleware#41-double-pass) support.
6+
7+
So you can call your middleware in both styles.
8+
9+
*Standard PSR-15 call:*
10+
11+
```php
12+
$middeware->process($request, $delegate);
13+
```
14+
15+
*Possible call after implements this package:*
16+
17+
```php
18+
$middleware($request, $response, $next);
19+
```
20+
21+
## Installation
22+
23+
```bash
24+
composer require php-middleware/double-pass-compatibility
25+
```
26+
27+
and add trait into your middeware:
28+
29+
```php
30+
class Middleware implements MiddlewareInterface
31+
{
32+
use PhpMiddleware\DoublePassCompatibilityTrait;
33+
34+
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
35+
{
36+
// Implementation and return response
37+
}
38+
}
39+
```
40+
41+
or extend abstract class:
42+
43+
```php
44+
class Middleware extend AbstractDoublePassCompatibilityMiddleware implements MiddlewareInterface
45+
{
46+
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
47+
{
48+
// Implementation and return response
49+
}
50+
}
51+
```

0 commit comments

Comments
 (0)