Skip to content

Commit 78c1832

Browse files
committed
Update documentation
1 parent e185825 commit 78c1832

1 file changed

Lines changed: 28 additions & 3 deletions

File tree

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# middleware-collection-request-handler
22

3-
A simple PSR-15 server request handler implementation to handle middleware collection.
3+
Lightweight & simple PSR-15 server request handler implementation to handle middleware collection.
44

55
![PHP from Packagist](https://img.shields.io/packagist/php-v/noglitchyo/middleware-collection-request-handler.svg)
66
[![Build Status](https://travis-ci.org/noglitchyo/middleware-collection-request-handler.svg?branch=master)](https://travis-ci.org/noglitchyo/middleware-collection-request-handler)
@@ -13,19 +13,44 @@ A simple PSR-15 server request handler implementation to handle middleware colle
1313
Request handler implementing the [RequestHandlerInterface](https://github.com/php-fig/http-server-handler/blob/master/src/RequestHandlerInterface.php)
1414
and able to manage a collection of middlewares implementing the [MiddlewareInterface](https://github.com/php-fig/http-server-middleware/blob/master/src/MiddlewareInterface.php).
1515

16-
This middleware attempts to provide interoperability to process a collection middlewares and
17-
offer the possibility to define the strategy on how middlewares are fetched.
16+
This middleware attempts to provide interoperability to process a collection of middlewares and
17+
give the possibility to define the strategy on how middlewares are fetched.
1818

1919
### Getting started
2020

2121
#### Installation
2222

2323
`composer require noglitchyo/middleware-collection-request-handler`
2424

25+
#### Run
26+
27+
The RequestHandler class only need 2 arguments:
28+
29+
- A default request handler (implementing [RequestHandlerInterface](https://github.com/php-fig/http-server-handler/blob/master/src/RequestHandlerInterface.php))
30+
31+
It is there to provide the response if no middleware created one.
32+
For example, you are using ADR pattern, the default request handler might be your Action.
33+
It is also possible to directly provide a `callable` using `RequestHandler::fromCallable()`.
34+
It will generate a generic instance of RequestHandlerInterface wrapping the `callable` inside.
35+
36+
***Remember: the default request handler is responsible for providing a default response.***
37+
38+
- A middleware collection (implementing [MiddlewareCollectionInterface](https://github.com/noglitchyo/middleware-collection-request-handler/blob/master/src/MiddlewareCollectionInterface.php))
39+
40+
It defines how you store your middlewares and the strategy to retrieve them.
41+
Some implementations are provided by default and will probably fit your needs.
42+
They offers different strategies varying from the Stack to the Queue.
43+
44+
However, it is really simple to create you own collection if needed, since MiddlewareCollectionInterface requires only 3 methods.
45+
2546
#### Tests
2647

2748
`composer test`
2849

2950
### References
3051

3152
https://www.php-fig.org/psr/psr-15/
53+
54+
## License
55+
56+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

0 commit comments

Comments
 (0)