diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 8e05d04d..c71e090c 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -41,10 +41,9 @@ use CloudCreativity\LaravelJsonApi\Http\Responses\Responses; use CloudCreativity\LaravelJsonApi\Services\JsonApiService; use CloudCreativity\LaravelJsonApi\Validators\ValidatorErrorFactory; -use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Routing\ResponseFactory as ResponseFactoryContract; -use Illuminate\Routing\Router; use Illuminate\Support\ServiceProvider as BaseServiceProvider; +use Laravel\Lumen\Application; use Neomerx\JsonApi\Contracts\Document\DocumentFactoryInterface; use Neomerx\JsonApi\Contracts\Encoder\Handlers\HandlerFactoryInterface; use Neomerx\JsonApi\Contracts\Encoder\Parser\ParserFactoryInterface; @@ -85,11 +84,9 @@ class ServiceProvider extends BaseServiceProvider * @param ResponseFactoryContract $responses */ public function boot( - Router $router, - ResponseFactoryContract $responses + Application $router ) { $this->bootMiddleware($router); - $this->bootResponseMacro($responses); } /** @@ -116,13 +113,20 @@ public function register() * * @param Router $router */ - protected function bootMiddleware(Router $router) + protected function bootMiddleware(Application $router) { /** Laravel 5.4 */ if (method_exists($router, 'aliasMiddleware')) { $router->aliasMiddleware('json-api', BootJsonApi::class); $router->aliasMiddleware('json-api.authorize', AuthorizeRequest::class); $router->aliasMiddleware('json-api.validate', ValidateRequest::class); + } /** Lumen **/ + else if (method_exists($router, 'routeMiddleware')) { + $router->routeMiddleware([ + 'json-api' => BootJsonApi::class, + 'json-api.authorize' => AuthorizeRequest::class, + 'json-api.validate' => ValidateRequest::class, + ]); } /** Laravel 5.1|5.2|5.3 */ else { $router->middleware('json-api', BootJsonApi::class);