@@ -8,28 +8,32 @@ Event-driven, streaming plaintext HTTP and secure HTTPS server for [ReactPHP](ht
88
99* [ Quickstart example] ( #quickstart-example )
1010* [ Usage] ( #usage )
11- * [ Server] ( #server )
12- * [ StreamingServer] ( #streamingserver )
13- * [ listen()] ( #listen )
14- * [ Request] ( #request )
15- * [ Request parameters] ( #request-parameters )
16- * [ Query parameters] ( #query-parameters )
17- * [ Request body] ( #request-body )
18- * [ Streaming request] ( #streaming-request )
19- * [ Request method] ( #request-method )
20- * [ Cookie parameters] ( #cookie-parameters )
21- * [ Invalid request] ( #invalid-request )
22- * [ Response] ( #response )
23- * [ Deferred response] ( #deferred-response )
24- * [ Streaming response] ( #streaming-response )
25- * [ Response length] ( #response-length )
26- * [ Invalid response] ( #invalid-response )
27- * [ Default response headers] ( #default-response-headers )
28- * [ Middleware] ( #middleware )
29- * [ LimitConcurrentRequestsMiddleware] ( #limitconcurrentrequestsmiddleware )
30- * [ RequestBodyBufferMiddleware] ( #requestbodybuffermiddleware )
31- * [ RequestBodyParserMiddleware] ( #requestbodyparsermiddleware )
32- * [ Third-Party Middleware] ( #third-party-middleware )
11+ * [ Server] ( #server )
12+ * [ StreamingServer] ( #streamingserver )
13+ * [ listen()] ( #listen )
14+ * [ Request] ( #request )
15+ * [ Request parameters] ( #request-parameters )
16+ * [ Query parameters] ( #query-parameters )
17+ * [ Request body] ( #request-body )
18+ * [ Streaming request] ( #streaming-request )
19+ * [ Request method] ( #request-method )
20+ * [ Cookie parameters] ( #cookie-parameters )
21+ * [ Invalid request] ( #invalid-request )
22+ * [ Response] ( #response )
23+ * [ Deferred response] ( #deferred-response )
24+ * [ Streaming response] ( #streaming-response )
25+ * [ Response length] ( #response-length )
26+ * [ Invalid response] ( #invalid-response )
27+ * [ Default response headers] ( #default-response-headers )
28+ * [ Middleware] ( #middleware )
29+ * [ Custom middleware] ( #custom-middleware )
30+ * [ Third-Party Middleware] ( #third-party-middleware )
31+ * [ API] ( #api )
32+ * [ React\Http\Middleware] ( #reacthttpmiddleware )
33+ * [ StreamingRequestMiddleware] ( #streamingrequestmiddleware )
34+ * [ LimitConcurrentRequestsMiddleware] ( #limitconcurrentrequestsmiddleware )
35+ * [ RequestBodyBufferMiddleware] ( #requestbodybuffermiddleware )
36+ * [ RequestBodyParserMiddleware] ( #requestbodyparsermiddleware )
3337* [ Install] ( #install )
3438* [ Tests] ( #tests )
3539* [ License] ( #license )
@@ -1046,6 +1050,8 @@ Many common use cases involve validating, processing, manipulating the incoming
10461050HTTP request before passing it to the final business logic request handler.
10471051As such, this project supports the concept of middleware request handlers.
10481052
1053+ #### Custom middleware
1054+
10491055A middleware request handler is expected to adhere the following rules:
10501056
10511057* It is a valid ` callable ` .
@@ -1160,6 +1166,39 @@ $server = new Server(array(
11601166));
11611167```
11621168
1169+ #### Third-Party Middleware
1170+
1171+ While this project does provide the means to * use* middleware implementations
1172+ (see above), it does not aim to * define* how middleware implementations should
1173+ look like. We realize that there's a vivid ecosystem of middleware
1174+ implementations and ongoing effort to standardize interfaces between these with
1175+ [ PSR-15] ( https://www.php-fig.org/psr/psr-15/ ) (HTTP Server Request Handlers)
1176+ and support this goal.
1177+ As such, this project only bundles a few middleware implementations that are
1178+ required to match PHP's request behavior (see
1179+ [ middleware implementations] ( #react-http-middleware ) ) and otherwise actively
1180+ encourages third-party middleware implementations.
1181+
1182+ While we would love to support PSR-15 directly in ` react/http ` , we understand
1183+ that this interface does not specifically target async APIs and as such does
1184+ not take advantage of promises for [ deferred responses] ( #deferred-response ) .
1185+ The gist of this is that where PSR-15 enforces a ` ResponseInterface ` return
1186+ value, we also accept a ` PromiseInterface<ResponseInterface> ` .
1187+ As such, we suggest using the external
1188+ [ PSR-15 middleware adapter] ( https://github.com/friends-of-reactphp/http-middleware-psr15-adapter )
1189+ that uses on the fly monkey patching of these return values which makes using
1190+ most PSR-15 middleware possible with this package without any changes required.
1191+
1192+ Other than that, you can also use the above [ middleware definition] ( #middleware )
1193+ to create custom middleware. A non-exhaustive list of third-party middleware can
1194+ be found at the [ middleware wiki] ( https://github.com/reactphp/reactphp/wiki/Users#http-middleware ) .
1195+ If you build or know a custom middleware, make sure to let the world know and
1196+ feel free to add it to this list.
1197+
1198+ ## API
1199+
1200+ ### React\Http\Middleware
1201+
11631202#### LimitConcurrentRequestsMiddleware
11641203
11651204The ` LimitConcurrentRequestsMiddleware ` can be used to
@@ -1382,34 +1421,6 @@ new RequestBodyParserMiddleware(10 * 1024, 100); // 100 files with 10 KiB each
13821421 If you want to respect this setting, you have to check its value and
13831422 effectively avoid using this middleware entirely.
13841423
1385- #### Third-Party Middleware
1386-
1387- While this project does provide the means to * use* middleware implementations
1388- (see above), it does not aim to * define* how middleware implementations should
1389- look like. We realize that there's a vivid ecosystem of middleware
1390- implementations and ongoing effort to standardize interfaces between these with
1391- [ PSR-15] ( https://www.php-fig.org/psr/psr-15/ ) (HTTP Server Request Handlers)
1392- and support this goal.
1393- As such, this project only bundles a few middleware implementations that are
1394- required to match PHP's request behavior (see above) and otherwise actively
1395- encourages third-party middleware implementations.
1396-
1397- While we would love to support PSR-15 directy in ` react/http ` , we understand
1398- that this interface does not specifically target async APIs and as such does
1399- not take advantage of promises for [ deferred responses] ( #deferred-response ) .
1400- The gist of this is that where PSR-15 enforces a ` ResponseInterface ` return
1401- value, we also accept a ` PromiseInterface<ResponseInterface> ` .
1402- As such, we suggest using the external
1403- [ PSR-15 middleware adapter] ( https://github.com/friends-of-reactphp/http-middleware-psr15-adapter )
1404- that uses on the fly monkey patching of these return values which makes using
1405- most PSR-15 middleware possible with this package without any changes required.
1406-
1407- Other than that, you can also use the above [ middleware definition] ( #middleware )
1408- to create custom middleware. A non-exhaustive list of third-party middleware can
1409- be found at the [ middleware wiki] ( https://github.com/reactphp/http/wiki/Middleware ) .
1410- If you build or know a custom middleware, make sure to let the world know and
1411- feel free to add it to this list.
1412-
14131424## Install
14141425
14151426The recommended way to install this library is [ through Composer] ( https://getcomposer.org ) .
0 commit comments