|
8 | 8 | use Api\App\Middleware\ContentNegotiationMiddleware; |
9 | 9 | use Api\App\Middleware\DeprecationMiddleware; |
10 | 10 | use Api\App\Middleware\ResourceProviderMiddleware; |
11 | | -use Api\App\Middleware\ResponseMiddleware; |
12 | | -use Dot\ErrorHandler\ErrorHandlerInterface; |
13 | 11 | use Dot\ResponseHeader\Middleware\ResponseHeaderMiddleware; |
14 | 12 | use Mezzio\Application; |
15 | 13 | use Mezzio\Cors\Middleware\CorsMiddleware; |
|
25 | 23 | use Mezzio\Router\Middleware\RouteMiddleware; |
26 | 24 |
|
27 | 25 | return function (Application $app): void { |
28 | | - // The error handler should be the first (most outer) middleware to catch |
29 | | - // all Exceptions. |
30 | | - $app->pipe(ErrorHandlerInterface::class); |
| 26 | + // This middleware must be the outest layer because - on error occurrence - it will: |
| 27 | + // - call \Dot\ErrorHandler\ErrorHandlerInterface::class |
| 28 | + // - return ProblemDetails response |
31 | 29 | $app->pipe(ProblemDetailsMiddleware::class); |
32 | 30 |
|
33 | 31 | $app->pipe(BodyParamsMiddleware::class); |
|
39 | 37 | // - pre-conditions |
40 | 38 | // - modifications to outgoing responses |
41 | 39 | // |
42 | | - // Piped Middleware may be either callables or service names. Middleware may |
43 | | - // also be passed as an array; each item in the array must resolve to |
44 | | - // middleware eventually (i.e., callable or service name). |
| 40 | + // Piped Middleware may be either callables or service names. |
| 41 | + // Middleware may also be passed as an array; each item in the array must resolve to middleware eventually |
| 42 | + // (i.e., callable or service name). |
45 | 43 | // |
46 | | - // Middleware can be attached to specific paths, allowing you to mix and match |
47 | | - // applications under a common domain. The handlers in each middleware |
48 | | - // attached this way will see a URI with the matched path segment removed. |
| 44 | + // Middleware can be attached to specific paths, allowing you to mix and match applications under a common domain. |
| 45 | + // The handlers in each middleware attached this way will see a URI with the matched path segment removed. |
49 | 46 | // |
50 | | - // i.e., path of "/api/member/profile" only passes "/member/profile" to $apiMiddleware |
| 47 | + // For example, the path of "/api/member/profile" only passes "/member/profile" to $apiMiddleware |
51 | 48 | // - $app->pipe('/api', $apiMiddleware); |
52 | 49 | // - $app->pipe('/docs', $apiDocMiddleware); |
53 | 50 | // - $app->pipe('/files', $filesMiddleware); |
|
84 | 81 | // - route-based validation |
85 | 82 | // - etc. |
86 | 83 |
|
87 | | - $app->pipe(ResponseMiddleware::class); |
88 | 84 | $app->pipe(ResourceProviderMiddleware::class); |
89 | 85 |
|
90 | 86 | // Register the dispatch middleware in the middleware pipeline |
|
0 commit comments