Skip to content

Commit

Permalink
fix: route registration of EntrypointController should be last
Browse files Browse the repository at this point in the history
Fixes #2767
  • Loading branch information
BurningDog authored and soyuka committed Sep 23, 2024
1 parent 0ab3cf4 commit 419c8d2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/Laravel/ApiPlatformProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1293,14 +1293,6 @@ public function boot(ResourceNameCollectionFactoryInterface $resourceNameCollect
$route->name('api_doc')->middleware(ApiPlatformMiddleware::class);
$routeCollection->add($route);

$route = new Route(['GET'], $prefix.'/{index?}{_format?}', function (Request $request, Application $app) {
$entrypointAction = $app->make(EntrypointController::class);

return $entrypointAction->__invoke($request);
});
$route->where('index', 'index');
$route->name('api_entrypoint')->middleware(ApiPlatformMiddleware::class);
$routeCollection->add($route);
$route = new Route(['GET'], $prefix.'/.well-known/genid/{id}', function (): void {
throw new NotExposedHttpException('This route is not exposed on purpose. It generates an IRI for a collection resource without identifier nor item operation.');
});
Expand All @@ -1323,6 +1315,15 @@ public function boot(ResourceNameCollectionFactoryInterface $resourceNameCollect
$routeCollection->add($route);
}

$route = new Route(['GET'], $prefix.'/{index?}{_format?}', function (Request $request, Application $app) {
$entrypointAction = $app->make(EntrypointController::class);

return $entrypointAction->__invoke($request);
});
$route->where('index', 'index');
$route->name('api_entrypoint')->middleware(ApiPlatformMiddleware::class);
$routeCollection->add($route);

$router->setRoutes($routeCollection);
}

Expand Down

0 comments on commit 419c8d2

Please sign in to comment.