1 | <?php |
||
9 | class BodyParserMiddleware implements MiddlewareInterface |
||
10 | { |
||
11 | /** |
||
12 | * Process an incoming request and/or response. |
||
13 | * |
||
14 | * Accepts a server-side request and a response instance, and does |
||
15 | * something with them. |
||
16 | * |
||
17 | * If the response is not complete and/or further processing would not |
||
18 | * interfere with the work done in the middleware, or if the middleware |
||
19 | * wants to delegate to another process, it can use the `$out` callable |
||
20 | * if present. |
||
21 | * |
||
22 | * If the middleware does not return a value, execution of the current |
||
23 | * request is considered complete, and the response instance provided will |
||
24 | * be considered the response to return. |
||
25 | * |
||
26 | * Alternately, the middleware may return a response instance. |
||
27 | * |
||
28 | * Often, middleware will `return $out();`, with the assumption that a |
||
29 | * later middleware will return a response. |
||
30 | * |
||
31 | * @param Request $request |
||
32 | * @param Response $response |
||
33 | * @param null|callable $out |
||
34 | * @return null|Response |
||
35 | */ |
||
36 | 3 | public function __invoke(Request $request, Response $response, callable $out = null) |
|
54 | |||
55 | /** |
||
56 | * @param Request $request |
||
57 | * @return string |
||
58 | */ |
||
59 | 3 | protected function getRequestContentType(Request $request) |
|
65 | |||
66 | /** |
||
67 | * @param Request $request |
||
68 | * @return Request |
||
69 | */ |
||
70 | 1 | protected function parseFromJson(Request $request) |
|
84 | |||
85 | /** |
||
86 | * @param Request $request |
||
87 | * @return Request |
||
88 | */ |
||
89 | 2 | protected function parseFromUrlEncoded(Request $request) |
|
101 | } |
||
102 |