PrepareController middleware is being run too early (before user-defined middleware) since beta4?
- Dominant language
- PHP
- Stars
- 9.4k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
Since we last upgraded Dingo API, we started having strange issues on our API. I'm pretty sure I narrowed down the issue to the switch between beta3 and beta4, ~~but I'm not 100% certain~~ confirmed as true.
We declare route middlewares like this:
```php
$app->routeMiddleware([
'mw1' => Middleware1::class,
'mw2' => Middleware2::class,
'mw3' => Middleware3::class,
]);
```
And we use them like this:
```php
$api = app(Router::class);
$api->version(
'v1',
function ($api) {
$api->group(
['middleware' => ['mw1', 'mw2', 'mw3']],
function ($api) {
$api->get(
'/endpoint/{parameter}',
Controllers\EndpointController::class
);
}
);
}
);
```
None of the middlewares are actually applied. The middlewares themselves don't seem to be related to the issue, they are not even instantiated once. I tried switching them to application middlewares with `$app->middleware()` instead and the problem disappears. It's just that I can't have these run for every request, so it's not a suitable workaround. Also, it doesn't seem to work either when I switch them to a single route.
Is that something we're doing wrong or did something change recently? Seems strange that we'd be the only ones to have this issue.
Contributor guide
Assessment
This issue has not been assessed yet.