Skip to content

Commit a6ccc26

Browse files
committed
Merge branch 'master' of github.com:/noglitchyo/middleware-collection-request-handler
2 parents f0a0fc6 + 9a0f9bd commit a6ccc26

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ It comes with a set of middleware collections using different strategy on how to
3232

3333
#### Run
3434

35-
Instantiate the RequestHandler class. It requires ony 2 arguments:
35+
Instantiate the RequestHandler class. It requires ony 2 arguments:
3636

37-
- `$defaultRequestHandler` ([RequestHandlerInterface](https://github.com/php-fig/http-server-handler/blob/master/src/RequestHandlerInterface.php))
37+
- ***`$defaultRequestHandler`*** : [RequestHandlerInterface](https://github.com/php-fig/http-server-handler/blob/master/src/RequestHandlerInterface.php)
3838

39-
***The default request handler is responsible to provide a default response if none of the middlewares created one.***
39+
***The default request handler MUST provide a default response if none of the middlewares created one.***
4040

41-
Some examples of "default request handler":
42-
- with the [ADR pattern](https://en.wikipedia.org/wiki/Action%E2%80%93domain%E2%80%93responder), the default request handler might be your action class.
43-
- with the [MVC pattern](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller), the default request handler might be the action method of your controller.
41+
Some examples of what could be a "default request handler":
42+
- with the [ADR pattern](https://en.wikipedia.org/wiki/Action%E2%80%93domain%E2%80%93responder), the default request handler might be your action class.*
43+
- with the [MVC pattern](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller), the default request handler might be the action method of your controller.
4444

45-
It is possible to directly provide a `callable` and use the factory method `RequestHandler::fromCallable(callable $callable)`.
46-
It will create an anonymous instance of RequestHandlerInterface wrapping the given `callable` inside.
45+
It is possible to directly provide a `callable` and use the factory method `RequestHandler::fromCallable(callable $callable)`.
46+
It will create an anonymous instance of RequestHandlerInterface wrapping the given `callable` inside.
4747

48-
- `$middlewareCollection` ([MiddlewareCollectionInterface](https://github.com/noglitchyo/middleware-collection-request-handler/blob/master/src/MiddlewareCollectionInterface.php))
48+
- ***`$middlewareCollection`*** : [MiddlewareCollectionInterface](https://github.com/noglitchyo/middleware-collection-request-handler/blob/master/src/MiddlewareCollectionInterface.php)
4949

50-
Contains the middlewares and encapsulate the strategy used to store and retrieve the middlewares.
51-
Some standard implementations are provided with different strategies: [stack (LIFO)](https://github.com/noglitchyo/middleware-collection-request-handler/blob/master/src/Collection/SplStackMiddlewareCollection.php), [queue (FIFO)](https://github.com/noglitchyo/middleware-collection-request-handler/blob/master/src/Collection/SplQueueMiddlewareCollection.php).
50+
Contains the middlewares and defines the strategy used to store the middlewares and to retrieve the next middleware.
51+
Some implementations with common strategies are provided: [stack (LIFO)](https://github.com/noglitchyo/middleware-collection-request-handler/blob/master/src/Collection/SplStackMiddlewareCollection.php), [queue (FIFO)](https://github.com/noglitchyo/middleware-collection-request-handler/blob/master/src/Collection/SplQueueMiddlewareCollection.php).
5252

5353
##### Example
5454

@@ -63,7 +63,8 @@ use Psr\Http\Message\ServerRequestInterface;
6363
use Psr\Http\Server\RequestHandlerInterface;
6464
use Psr\Http\Message\ResponseInterface;
6565

66-
// Instantiate a collection of middleware.
66+
// Instantiate a collection of middlewares with an anonymous middleware class.
67+
// In this example, we are using a "stack" implementation of the collection.
6768
$middlewareCollection = new SplStackMiddlewareCollection([
6869
new class implements MiddlewareInterface{
6970
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface{
@@ -85,7 +86,7 @@ $requestHandler = RequestHandler::fromCallable(
8586
$middlewareCollection
8687
);
8788

88-
// Pass the request to the request handler.
89+
// Pass the request to the request handler which will dispatch the request to the middlewares.
8990
$response = $requestHandler->handle(/* ServerRequestInterface */);
9091

9192
```

0 commit comments

Comments
 (0)