Skip to content

Commit f1580b3

Browse files
authored
Merge pull request #314 from clue-labs/psr-15
Documentation for PSR-15 middleware
2 parents 327bdfe + aad8a48 commit f1580b3

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,9 @@ or use a class based approach to ease using existing middleware implementations.
831831
While this project does provide the means to *use* middleware implementations,
832832
it does not aim to *define* how middleware implementations should look like.
833833
We realize that there's a vivid ecosystem of middleware implementations and
834-
ongoing effort to standardize interfaces between these and support this goal.
834+
ongoing effort to standardize interfaces between these with
835+
[PSR-15](https://www.php-fig.org/psr/psr-15/) (HTTP Server Request Handlers)
836+
and support this goal.
835837
As such, this project only bundles a few middleware implementations that are
836838
required to match PHP's request behavior (see below) and otherwise actively
837839
encourages [Third-Party Middleware](#third-party-middleware) implementations.
@@ -1135,7 +1137,31 @@ new RequestBodyParserMiddleware(10 * 1024, 100); // 100 files with 10 KiB each
11351137

11361138
#### Third-Party Middleware
11371139

1138-
A non-exhaustive list of third-party middleware can be found at the [`Middleware`](https://github.com/reactphp/http/wiki/Middleware) wiki page.
1140+
While this project does provide the means to *use* middleware implementations
1141+
(see above), it does not aim to *define* how middleware implementations should
1142+
look like. We realize that there's a vivid ecosystem of middleware
1143+
implementations and ongoing effort to standardize interfaces between these with
1144+
[PSR-15](https://www.php-fig.org/psr/psr-15/) (HTTP Server Request Handlers)
1145+
and support this goal.
1146+
As such, this project only bundles a few middleware implementations that are
1147+
required to match PHP's request behavior (see above) and otherwise actively
1148+
encourages third-party middleware implementations.
1149+
1150+
While we would love to support PSR-15 directy in `react/http`, we understand
1151+
that this interface does not specifically target async APIs and as such does
1152+
not take advantage of promises for [deferred responses](#deferred-response).
1153+
The gist of this is that where PSR-15 enforces a `ResponseInterface` return
1154+
value, we also accept a `PromiseInterface<ResponseInterface>`.
1155+
As such, we suggest using the external
1156+
[PSR-15 middleware adapter](https://github.com/friends-of-reactphp/http-middleware-psr15-adapter)
1157+
that uses on the fly monkey patching of these return values which makes using
1158+
most PSR-15 middleware possible with this package without any changes required.
1159+
1160+
Other than that, you can also use the above [middleware definition](#middleware)
1161+
to create custom middleware. A non-exhaustive list of third-party middleware can
1162+
be found at the [middleware wiki](https://github.com/reactphp/http/wiki/Middleware).
1163+
If you build or know a custom middleware, make sure to let the world know and
1164+
feel free to add it to this list.
11391165

11401166
## Install
11411167

0 commit comments

Comments
 (0)