You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and able to manage a collection of Middlewares implementing the [MiddlewareInterface](https://github.com/php-fig/http-server-middleware/blob/master/src/MiddlewareInterface.php).
able to manage a collection of middlewares implementing the [MiddlewareInterface](https://github.com/php-fig/http-server-middleware/blob/master/src/MiddlewareInterface.php).
15
15
16
-
It comes with a set of middleware collections using different strategy on how to provide the middlewares to the RequestHandler, and also provide a dead simple collection interface to implement in a glimpse your own strategy.
16
+
It can be used either as a RequestHandler or as a Middleware to fit into any implementation.
17
+
18
+
Comes with a set of middleware collections using different strategy (LIFO, FIFO...) on how the middlewares from the collection are provided to the RequestHandler, and also provides a simple MiddlewareCollectionInterface to implement in a glimpse your own strategy.
17
19
18
20
### Goals
19
21
@@ -32,23 +34,31 @@ It comes with a set of middleware collections using different strategy on how to
32
34
33
35
#### Run
34
36
35
-
Instantiate the RequestHandler class. It requires ony 2 arguments:
37
+
Create a new instance of the request handler class which can be use as a request handler or as a middleware.
Contains the middlewares and defines the strategy used to store the middlewares and to retrieve the next middleware.
46
+
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).
***The default request handler MUST provide a default response if none of the middlewares created one.***
50
+
Provides a default response implementing [ResponseInterface](https://github.com/php-fig/http-message/blob/master/src/ResponseInterface.php)if none of the middlewares in the collection was able to create one.
40
51
41
52
Some examples of what could be a "default request handler":
42
53
- 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
54
- 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.
44
55
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.
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).
It creates a RequestHandler instance by wrapping the given `callable` inside an anonymous instance of RequestHandlerInterface.
61
+
The callable is the $defaultRequestHandler. **It MUST returns a response implementing [ResponseInterface](https://github.com/php-fig/http-message/blob/master/src/ResponseInterface.php).**
0 commit comments